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

Draft: transform/from_base64: Signal error condition (use with absent) #12337

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

jlucovsky
Copy link
Contributor

Extend the from_base64 transform to signal cases when the buffer cannot be base64-decoded.

A transform option named set_error is added to modify the transform buffer. By default, the transform buffer is unmodified if the content cannot be base64-decoded. If set_error is specified as a transform option and the buffer can't be base64-decoded, the buffer is truncated. In these cases, the absent keyword can be used with set_error to trigger an alert.

For example: content:"/?arg="; from_base64: set_error; absent; will trigger an alert since the content is not base64-encoded.

Link to ticket: https://redmine.openinfosecfoundation.org/issues/7114

Describe changes:

  • Update transform option parser to recognize set_error
  • Document set_error behavior
  • Update the transform to truncate the buffer if set_error was specified and the buffer cannot be base64-decoe.

Provide values to any of the below to override the defaults.

  • To use an LibHTP, Suricata-Verify or Suricata-Update pull request,
    link to the pull request in the respective _BRANCH variable.
  • Leave unused overrides blank or remove.

SV_REPO=
SV_BRANCH=OISF/suricata-verify#2212
SU_REPO=
SU_BRANCH=
LIBHTP_REPO=
LIBHTP_BRANCH=

Issue: 7114

Extend the `from_base64` transform with the `set_error` keyword. This
can be used to detect whether the input buffer is base64-encoded or not.

When `set_error` is used and the content cannot be base64-decoded, the
use of the absent keyword will trigger an alert.
Use set_error to signal when a buffer cannot be base64-decoded.

This example uses set_error and absent to alert on a buffer that cannot
be base64-decoded:

    content:"/?arg="; from_base64: set_error; absent;

This example uses set_error and absent to alert on a buffer that cannot
be base64-decoded or if it can, matches the content shown::

    content:"/?arg=dGhpc2lzYXRlc3QK"; from_base64: offset 10; \
    absent: or_else; content:"sisatest"

Issue: 7114
Typo fixup for error message when there's no bufer available for the
absent keyword..
Issue: 7114

Support absent keyword with empty buffers, such as those from a failed
transform.
Copy link

codecov bot commented Jan 4, 2025

Codecov Report

Attention: Patch coverage is 93.61702% with 3 lines in your changes missing coverage. Please review.

Project coverage is 83.23%. Comparing base (6f937c7) to head (f0cdc14).
Report is 5 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #12337      +/-   ##
==========================================
- Coverage   83.26%   83.23%   -0.03%     
==========================================
  Files         912      912              
  Lines      257643   257684      +41     
==========================================
- Hits       214521   214479      -42     
- Misses      43122    43205      +83     
Flag Coverage Δ
fuzzcorpus 61.21% <35.29%> (+0.07%) ⬆️
livemode 19.39% <11.76%> (-0.01%) ⬇️
pcap 44.40% <11.76%> (-0.02%) ⬇️
suricata-verify 62.87% <76.47%> (+<0.01%) ⬆️
unittests 59.19% <80.85%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

@suricata-qa
Copy link

Information: QA ran without warnings.

Pipeline 24074

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