Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

detect/bsize: Validate against content buffer when available #4997

Closed
wants to merge 3 commits into from

Conversation

jlucovsky
Copy link
Contributor

Continuation of #4991

This PR adds additional validation when using the bsize keyword. If a one or more content keywords immediately precedes bsize, then the bsize value is checked against each to see if a match is possible using the operation (=, <, >, <>) and the value.

An error is raised if bsize value prevents a match, e.g., the content length exceeds the bsize value. The bsize operation and values are used to do the evaluation.

Link to redmine ticket: 3682

Describe changes:

  • Incorporate offset value when validating bsize value.

Companion Suricata PR #233

This commit updates the bsize documentation

1. Describe what happens when "content" immediately precedes "bsize"
2. Include the operators and
3. Include examples using the operators.
This commit causes the signature to be invalid if a content keyword
immediately precedes bsize and the bsize value is incompatible with the
content length.
This commit adds test cases that validate behavior when "content"
immediately precedes "bsize".

static bool DetectBsizeCheckContent(const SigMatch *sm, const DetectBsizeData *bsz)
{
uint16_t bytes_required;
Copy link
Member

Choose a reason for hiding this comment

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

if none of the members of the list are content the error message will use this uninitialized variable.

Copy link
Member

Choose a reason for hiding this comment

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

also: the error won't make sense at all in this case


static bool DetectBsizeCheckContent(const SigMatch *sm, const DetectBsizeData *bsz)
{
uint16_t bytes_required;
Copy link
Member

Choose a reason for hiding this comment

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

also: the error won't make sense at all in this case

@jlucovsky
Copy link
Contributor Author

Continued in #5014

@jlucovsky jlucovsky closed this Jun 3, 2020
@jlucovsky jlucovsky deleted the 3682/6 branch October 8, 2020 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants