Skip to content

Reject excessively long dst, src, and localip ACL parameters - #2478

Open
k-furman wants to merge 2 commits into
squid-cache:masterfrom
k-furman:fix-buffer-overflow-in-ip.cc
Open

Reject excessively long dst, src, and localip ACL parameters#2478
k-furman wants to merge 2 commits into
squid-cache:masterfrom
k-furman:fix-buffer-overflow-in-ip.cc

Conversation

@k-furman

@k-furman k-furman commented Aug 20, 2026

Copy link
Copy Markdown

This change fixes buffer overflows when acl_ip_data::FactoryParse() is
given malformed dst, src, and localip ACL configuration parameters
with values exceeding 255 characters. Squid now also detects (and
rejects) trailing parameter garbage in more cases.

FactoryParse() sscanf() calls were writing raw input into 256-byte
buffers without checking input size. This change adds these limits:

  • IPv6 input patterns: 39 bytes per address and 3 bytes for the mask.
  • IPv4 input patterns: 15 bytes per address and 15 bytes for the mask.
  • Non-IP input patterns: 255 per address and 255 for the mask.

We now also extend trailing garbage checks to all of the above patterns.

@squid-anubis squid-anubis added the M-failed-description https://github.com/measurement-factory/anubis#pull-request-labels label Aug 20, 2026
@squid-anubis

This comment was marked as resolved.

@squid-anubis squid-anubis removed the M-failed-description https://github.com/measurement-factory/anubis#pull-request-labels label Aug 20, 2026
@rousskov rousskov changed the title Fix possible buffer-overflow in acl_ip_data::FactoryParse Reject excessively long dst, src, and localip ACL parameters Aug 20, 2026

@rousskov rousskov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you for posting this PR. It needs a few corrections, but nothing major AFAICT. Please let me know if you want me to do any of the suggested changes.

Please check the adjusted PR title/description. They will become a commit message when this PR is merged. I edited them to focus the title on admin-visible effects and to avoid retelling what the diff clearly says. I also wanted to clarify the scope of the proposed trailing garbage checks.

Finally, please add the author line from the first PR branch commit (or, if needed, an alternative entry) to CONTRIBUTORS. Our CI tests will check for that automatically. If you do not want any such entry, please let me know, and we will take care of that manually.

Comment thread src/acl/Ip.cc Outdated
Comment thread src/acl/Ip.cc Outdated
Comment thread src/acl/Ip.cc Outdated
Comment thread src/acl/Ip.cc Outdated
Comment thread src/acl/Ip.cc Outdated
Comment thread src/acl/Ip.cc Outdated
Comment thread src/acl/Ip.cc Outdated
@rousskov rousskov added the S-waiting-for-author author action is expected (and usually required) label Aug 20, 2026
This change fixes buffer overflows when acl_ip_data::FactoryParse() is
given malformed dst, src, and localip ACL configuration parameters
with values exceeding 255 characters. Squid now also detects (and
rejects) trailing parameter garbage in more cases.

FactoryParse() sscanf() calls were writing raw input into 256-byte
buffers without checking input size. This change adds these limits:

- IPv6 input patterns: 39 bytes per address and 3 bytes for the mask.
- IPv4 input patterns: 15 bytes per address and 15 bytes for the mask.
- Non-IP input patterns: 255 per address and 255 for the mask.

We now also extend trailing garbage checks to all of the above patterns.
@k-furman
k-furman force-pushed the fix-buffer-overflow-in-ip.cc branch from 15309af to c72b844 Compare August 21, 2026 12:53
@k-furman

Copy link
Copy Markdown
Author

Many thanks for detailed answer!

I fixed all things you suggested, squash commits, change commit message and head as in PR, and force-pushed it.

Also, I add a line with my name in CONTRIBUTORS, as you tell.

@k-furman
k-furman requested a review from rousskov August 21, 2026 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-for-author author action is expected (and usually required)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants