-
Notifications
You must be signed in to change notification settings - Fork 662
Reject excessively long dst, src, and localip ACL parameters #2478
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -17,6 +17,7 @@ | |||||||
| #include "debug/Stream.h" | ||||||||
| #include "ip/tools.h" | ||||||||
| #include "MemBuf.h" | ||||||||
| #include "sbuf/Stream.h" | ||||||||
| #include "wordlist.h" | ||||||||
|
|
||||||||
| #include <algorithm> | ||||||||
|
|
@@ -230,15 +231,18 @@ acl_ip_data::containsVetted(const Ip::Address &needle) const | |||||||
| } | ||||||||
|
|
||||||||
| /* Handle either type of address, IPv6 will be discarded with a warning if disabled */ | ||||||||
| #define SCAN_ACL1_6 "%[0123456789ABCDEFabcdef:]-%[0123456789ABCDEFabcdef:]/%[0123456789]" | ||||||||
| #define SCAN_ACL2_6 "%[0123456789ABCDEFabcdef:]-%[0123456789ABCDEFabcdef:]%c" | ||||||||
| #define SCAN_ACL3_6 "%[0123456789ABCDEFabcdef:]/%[0123456789]" | ||||||||
| #define SCAN_ACL4_6 "%[0123456789ABCDEFabcdef:]/%c" | ||||||||
| #define SCAN_ACL1_6 "%39[0123456789ABCDEFabcdef:]-%39[0123456789ABCDEFabcdef:]/%3[0123456789]" | ||||||||
| #define SCAN_ACL2_6 "%39[0123456789ABCDEFabcdef:]-%39[0123456789ABCDEFabcdef:]%c" | ||||||||
| #define SCAN_ACL3_6 "%39[0123456789ABCDEFabcdef:]/%3[0123456789]" | ||||||||
| #define SCAN_ACL4_6 "%39[0123456789ABCDEFabcdef:]/%c" | ||||||||
| /* We DO need to know which is which though, for proper CIDR masking. */ | ||||||||
| #define SCAN_ACL1_4 "%[0123456789.]-%[0123456789.]/%[0123456789.]" | ||||||||
| #define SCAN_ACL2_4 "%[0123456789.]-%[0123456789.]%c" | ||||||||
| #define SCAN_ACL3_4 "%[0123456789.]/%[0123456789.]" | ||||||||
| #define SCAN_ACL4_4 "%[0123456789.]/%c" | ||||||||
| #define SCAN_ACL1_4 "%15[0123456789.]-%15[0123456789.]/%15[0123456789.]" | ||||||||
| #define SCAN_ACL2_4 "%15[0123456789.]-%15[0123456789.]%c" | ||||||||
| #define SCAN_ACL3_4 "%15[0123456789.]/%15[0123456789.]" | ||||||||
| #define SCAN_ACL4_4 "%15[0123456789.]/%c" | ||||||||
| /* Handle non-ip/incorrect patterns */ | ||||||||
| #define SCAN_ACLX_1 "%255[^/]/%255s" | ||||||||
| #define SCAN_ACLX_2 "%255s" | ||||||||
|
|
||||||||
| acl_ip_data * | ||||||||
| acl_ip_data::FactoryParse(const char *t) | ||||||||
|
|
@@ -292,10 +296,10 @@ acl_ip_data::FactoryParse(const char *t) | |||||||
| iptype=AF_INET6; | ||||||||
|
|
||||||||
| // Neither | ||||||||
| } else if (sscanf(t, "%[^/]/%s", addr1, mask) == 2) { | ||||||||
| debugs(28, 9, "aclIpParseIpData: '" << t << "' matched: non-IP pattern: %[^/]/%s"); | ||||||||
| } else if (sscanf(t, SCAN_ACLX_1, addr1, mask) == 2) { | ||||||||
| debugs(28, 9, "aclIpParseIpData: '" << t << "' matched: non-IP pattern: " << SCAN_ACLX_1); | ||||||||
| addr2[0] = '\0'; | ||||||||
| } else if (sscanf(t, "%s", addr1) == 1) { | ||||||||
| } else if (sscanf(t, SCAN_ACLX_2, addr1) == 1) { | ||||||||
| /* | ||||||||
| * Note, must use plain getaddrinfo() here because at startup | ||||||||
| * ipcache hasn't been initialized | ||||||||
|
|
@@ -357,6 +361,9 @@ acl_ip_data::FactoryParse(const char *t) | |||||||
| } | ||||||||
|
|
||||||||
| return q; | ||||||||
| } else { | ||||||||
| delete q; | ||||||||
| throw TextException(ToSBuf("Excessively long ACL parameter value: ", t), Here()); | ||||||||
|
Comment on lines
+364
to
+366
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are almost done, I hope. AFAICT, we should now remove this new code as unreachable and adjust PR title to replace the specific "reject" claim with something vague like "Improve handling of long dst, src, and localip ACL parameters".
Suggested change
If the above is correct, please remove the no-longer-necessary |
||||||||
| } | ||||||||
|
|
||||||||
| /* ignore IPv6 addresses when built with IPv4-only */ | ||||||||
|
|
||||||||
Uh oh!
There was an error while loading. Please reload this page.