Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

HPACK decoder fixes #39907

Merged
merged 4 commits into from
Aug 2, 2019
Merged

Conversation

scalablecory
Copy link

  • Fix HPACK decoder failing inconsistently with 0-length header names. Fail fast with same exception message that HTTP1 uses. Resolves #39873.
  • Fix DynamicTable returning incorrect values or throwing exceptions when it wraps its ring buffer. Resolves #39656.
  • Moves HPACK encoder methods from Http2LoopbackConnection into their own class.
  • Implement all forms of header encodings in HPACK encoder.
  • Move a number of files where they belong into the ProductionCode folder in unit test project.

Cory Nelson added 2 commits July 30, 2019 16:48
@scalablecory scalablecory added this to the 5.0 milestone Jul 31, 2019
@scalablecory scalablecory requested review from stephentoub and a team July 31, 2019 00:23
@scalablecory scalablecory self-assigned this Jul 31, 2019
@@ -265,6 +270,7 @@ public void Decode(ReadOnlySpan<byte> data, bool endHeaders, HeaderCallback onHe
case State.HeaderNameLengthContinue:
if (_integerDecoder.Decode(b))
{
Debug.Assert(_integerDecoder.Value != 0, "HPACK integer decoder failed to stop an overlong 0.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does "an overlong 0" mean?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

over long encoding. the integer 0 should take only a single byte, any more and IntegerDecoder will throw an exception.

Copy link
Member

@stephentoub stephentoub Jul 31, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still having trouble parsing this. By "over long", do you mean "too long" / "too many bytes"?

Not trying to nitpick, I just wouldn't know how to react if this assert failed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's terminology that came to me via UTF-8 security issues and I'm realizing now that it may not be common knowledge. I will update the assert message with something else.

Overlong encoding means an integer was encoded in more bytes than was required. IntegerDecoder does not allow this. The assert is there mostly as documentation that we don't need to check the 0 case on continuation bytes because it is prevented elsewhere.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Wasn't familiar with the term. Thanks for the explanation.

@scalablecory
Copy link
Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 4 pipeline(s).

@scalablecory
Copy link
Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 4 pipeline(s).

@scalablecory
Copy link
Author

Can't seem to get a reliable CI run today. Guess I'll try later once everyone is asleep :).

@JamesNK
Copy link
Member

JamesNK commented Aug 1, 2019

Are these changes to code from ASP.NET Core HPACK? Should they be mirrored in aspnetcore? // @Tratcher

@scalablecory
Copy link
Author

@JamesNK yes it looks like both of these fixes willy apply to the ASP.NET version.

@Tratcher
Copy link
Member

Tratcher commented Aug 1, 2019

Fix DynamicTable returning incorrect values or throwing exceptions when it wraps its ring buffer. Resolves #39656.

Ug, I spent all day today debugging that. Amusingly our fixes look identical. dotnet/aspnetcore#12782

@scalablecory
Copy link
Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 4 pipeline(s).

@karelz karelz removed the bug Product bug (most likely) label Aug 1, 2019
@scalablecory
Copy link
Author

@stephentoub @dotnet/ncl any further review?

CI still failing in unrelated places. This is not platform-specific code so I think we're okay there as one of the outerloop runs got through successfully. @dotnet/dnceng @ViktorHofer @safern can anything be done about this?

Copy link
Member

@wfurt wfurt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@MattGal
Copy link
Member

MattGal commented Aug 1, 2019

@scalablecory - from a DncEng perspective, the only suspicious bit I see is the OSX legs where it seems the machines may not be properly interactively logged in with unlocked keychains; The other failures look like flaky tests (the system.net one hitting an HTTP Client timeout is classic flaky test behavior) or just a plain bug causing fact failure (FileSystemWatcher ones)

I'm checking out some of the macs and will discuss with folks about this; I believe many of them were recently reimaged and configuration might be subtly affected.

@MattGal
Copy link
Member

MattGal commented Aug 1, 2019

@scalablecory one more update; I don't see anything specifically wrong about the machines your OSX work ran on w.r.t. interactive login or keychains, but @ilyas1974 is going to take a peek as well later.

Thanks for bringing this to our attention!

@scalablecory
Copy link
Author

Thanks @MattGal

@ilyas1974
Copy link

It doing some investigation, it appears that they way Apple addresses the Key Chain functionality changed between 10.11/12 and 10.13/14. The configuration directory within /Library/Keychain no longer exists (where the permissions were originally changed in previous versions). As there is nothing to modify permissions on, the changes that we previous used do not apply.

/// </summary>
NeverIndexed = 8
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a second implementation of hpack encoding, separate from the product implementation?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I see, you consolidated existing test code, rather than writing it from scratch as part of this PR. Ok.

Copy link
Member

@stephentoub stephentoub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The product fix LGTM.

@scalablecory scalablecory merged commit b7e60c9 into dotnet:master Aug 2, 2019
scalablecory pushed a commit to scalablecory/corefx that referenced this pull request Aug 5, 2019
…. Fail fast with same exception message that HTTP1 uses. Resolves #39873.

Partial port of dotnet#39907 from master.
@ViktorHofer
Copy link
Member

@ViktorHofer @safern can anything be done about this?

We have been actively working on disabling/fixing flaky tests for quite some time. Our goal is to stabilize CI and rolling builds by end of the year latest. We have measurements in place that will help us achieve that goal.

scalablecory added a commit that referenced this pull request Aug 7, 2019
…0-length header names (#40042)

Fix HPACK decoder failing inconsistently with 0-length header names. Fail fast with same exception message that HTTP1 uses. Resolves #39873. Partial port of #39907 from master.
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
- Fix HPACK decoder failing inconsistently with 0-length header names. Fail fast with same exception message that HTTP1 uses. Resolves dotnet/corefx#39873.
- Fix `DynamicTable` returning incorrect values or throwing exceptions when it wraps its ring buffer. Resolves dotnet/corefx#39656.
- Moves HPACK encoder methods from `Http2LoopbackConnection` into their own class.
- Implement all forms of header encodings in HPACK encoder.
- Move a number of files where they belong into the ProductionCode folder in unit test project.

Commit migrated from dotnet/corefx@b7e60c9
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HTTP2: failure with 0-length header strings HTTP2: dynamic table error when insert index wraps
9 participants