Skip to content

Http2Settings: validate non-standard setting values#13369

Merged
normanmaurer merged 1 commit intonetty:4.1from
idelpivnitskiy:h2Settings
May 2, 2023
Merged

Http2Settings: validate non-standard setting values#13369
normanmaurer merged 1 commit intonetty:4.1from
idelpivnitskiy:h2Settings

Conversation

@idelpivnitskiy
Copy link
Copy Markdown
Member

Motivation:

RFC9113 Section 6.5.1 defines settings value as unsigned 32-bit. We should validate that users don't pass a long value outside of this range.

Modifications:

  • Http2Settings throws IllegalArgumentException if a non-standard setting has value outside unsigned 32-bit integer range;
  • Http2Settings.verifyStandardSetting always includes expected range when it throws IllegalArgumentException;
  • Enhance Http2SettingsTest to validate valid and invalid values for each setting;
  • Http2Settings.keyToString encodes non-standard settings as hex value;

Result:

Value range for non-standard settings is also validated. Exceptions always include expected range in the message.

Motivation:

RFC9113 Section 6.5.1 defines settings value as unsigned 32-bit.
We should validate that users don't pass a `long` value outside of this
range.

Modifications:

- `Http2Settings` throws `IllegalArgumentException` if a non-standard
setting has value outside unsigned 32-bit integer range;
- `Http2Settings.verifyStandardSetting` always includes expected range
when it throws `IllegalArgumentException`;
- Enhance `Http2SettingsTest` to validate valid and invalid values for
each setting;
- `Http2Settings.keyToString` encodes non-standard settings as hex
value;

Result:

Value range for non-standard settings is also validated.
Exceptions always include expected range in the message.
default:
// Unknown keys.
return super.keyToString(key);
return "0x" + toHexString(key);
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Lmk if you would like this as a separate PR for visibility in changelog

@idelpivnitskiy idelpivnitskiy requested a review from chrisvest May 1, 2023 18:38
@normanmaurer normanmaurer requested a review from ejona86 May 2, 2023 07:56
@normanmaurer
Copy link
Copy Markdown
Member

@ejona86 can you have a look as well ?

Copy link
Copy Markdown
Member

@trustin trustin left a comment

Choose a reason for hiding this comment

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

Nice work! Thanks, @idelpivnitskiy 🙇

@normanmaurer normanmaurer merged commit ce4e054 into netty:4.1 May 2, 2023
normanmaurer pushed a commit that referenced this pull request May 2, 2023
Motivation:

RFC9113 Section 6.5.1 defines settings value as unsigned 32-bit.
We should validate that users don't pass a `long` value outside of this
range.

Modifications:

- `Http2Settings` throws `IllegalArgumentException` if a non-standard
setting has value outside unsigned 32-bit integer range;
- `Http2Settings.verifyStandardSetting` always includes expected range
when it throws `IllegalArgumentException`;
- Enhance `Http2SettingsTest` to validate valid and invalid values for
each setting;
- `Http2Settings.keyToString` encodes non-standard settings as hex
value;

Result:

Value range for non-standard settings is also validated.
Exceptions always include expected range in the message.
@idelpivnitskiy idelpivnitskiy deleted the h2Settings branch May 2, 2023 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants