This repository was archived by the owner on Jun 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 120
Enforce limits of values read from incoming headers and app id lookup #608
Merged
Merged
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
bf5fce4
Updated CorrelationIdLookupHelper.GenerateCorrelationIdAndAddToDictio…
f813db6
marking files to guard Request Headers (todo)
6b3cee1
add request header guard statements
9f673f6
Enforce http header value sizes in more place
cijothomas 63328d5
Remove comment after adressingtodo
cijothomas 194d475
Enforce max length for baggage populated from context headers
cijothomas 5051ee4
Merge branch 'develop' into cithomas/fix_sdl_bugs
cijothomas bbee094
CorrelationIDlookUp helper is modified to match Web SDK logic which h…
cijothomas ff7bfce
Unittest fix
cijothomas acf9ea8
Moved appid validation so that validation triggered only for non-null…
cijothomas 58c0672
adjust unit test.
cijothomas fd96d32
Sergey's recommendation to allow headers up to 1Kb
f31ff24
Adjust max size of contents read from incoming request headers to be 1k
cijothomas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
src/Microsoft.ApplicationInsights.AspNetCore/Common/InjectionGuardConstants.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| namespace Microsoft.ApplicationInsights.AspNetCore.Common | ||
| { | ||
| /// <summary> | ||
| /// These values are listed to guard against malicious injections by limiting the max size allowed in an HTTP Response. | ||
| /// These max limits are intentionally exaggerated to allow for unexpected responses, while still guarding against unreasonably large responses. | ||
| /// Example: While a 32 character response may be expected, 50 characters may be permitted while a 10,000 character response would be unreasonable and malicious. | ||
| /// </summary> | ||
| public static class InjectionGuardConstants | ||
| { | ||
| /// <summary> | ||
| /// Max length of AppId allowed in response from Breeze. | ||
| /// </summary> | ||
| public const int AppIdMaxLengeth = 50; | ||
|
|
||
| /// <summary> | ||
| /// Max length of incoming Request Header value allowed. | ||
| /// </summary> | ||
| public const int RequestHeaderMaxLength = 100; | ||
|
|
||
| /// <summary> | ||
| /// Max length of context header key. | ||
| /// </summary> | ||
| public const int ContextHeaderKeyMaxLength = 50; | ||
|
|
||
| /// <summary> | ||
| /// Max length of context header value. | ||
| /// </summary> | ||
| public const int ContextHeaderValueMaxLength = 100; | ||
|
||
| } | ||
| } | ||
26 changes: 26 additions & 0 deletions
26
src/Microsoft.ApplicationInsights.AspNetCore/Common/StringUtilities.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| namespace Microsoft.ApplicationInsights.AspNetCore.Common | ||
| { | ||
| using System.Diagnostics; | ||
|
|
||
| /// <summary> | ||
| /// Generic functions to perform common operations on a string. | ||
| /// </summary> | ||
| public static class StringUtilities | ||
| { | ||
| /// <summary> | ||
| /// Check a strings length and trim to a max length if needed. | ||
| /// </summary> | ||
| public static string EnforceMaxLength(string input, int maxLength) | ||
| { | ||
| Debug.Assert(input != null, $"{nameof(input)} must not be null"); | ||
| Debug.Assert(maxLength > 0, $"{nameof(maxLength)} must be greater than 0"); | ||
|
|
||
| if (input != null && input.Length > maxLength) | ||
| { | ||
| input = input.Substring(0, maxLength); | ||
| } | ||
|
|
||
| return input; | ||
| } | ||
| } | ||
| } |
277 changes: 204 additions & 73 deletions
277
...cationInsights.AspNetCore/DiagnosticListeners/Implementation/CorrelationIdLookupHelper.cs
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i picked 50. Not sure if there is genuine need of key longer than this.