Repository navigation
Backport/6485 3.24.x - #6528
Backport/6485 3.24.x#6528victormlg wants to merge 24 commits into
Conversation
…hen matching /0 range Ticket: CFE-3081 Changelog: Fixed bug where isipinsubnet() fails to validate bogus IPv4 addresses when checking the 0.0.0.0/0 range (cherry picked from commit ffd3ce4)
AddressSanitizer, matching a pattern against a shorter address:
ERROR: AddressSanitizer: heap-buffer-overflow READ of size 1
#0 strlen
cfengine#1 sscanf
cfengine#2 FuzzySetMatch addr_lib.c
Noticed this reading the IP range matcher. FuzzySetMatch() splits an
address into octets with a fixed 4-iteration loop:
for (i = 0; i < 4; i++) {
sscanf(sp1, "%63[^.]", buffer1);
...
sscanf(sp2, "%63[^.]", buffer2);
sp2 += strlen(buffer2) + 1;
}
The +1 steps over the '.' separator. But on the last octet there is no
separator, so it steps over the terminating NUL instead. When s2 has
fewer octets than s1 (say pattern "1.2.3.4" against address "1"), sp2
walks past the end of the string and the next sscanf reads out of bounds.
buffer2 is not reset either, so a failed scan keeps stale content.
s2 reaches here from untrusted data through the isipinsubnet() and
iprange() policy functions, whose address argument is an arbitrary
string.
Only advance past a separator that is actually there, reset buffer2, and
stop with no match once the address runs out of octets. The IPv6 match
loop and the IPv4 range loop in FuzzyMatchParse() had the same walk-off,
fixed the same way. Added a regression test that trips ASan on the old
code.
Changelog: Title
Signed-off-by: Aizal Khan <aizumusheer2@gmail.com>
(cherry picked from commit f6288ee)
Covers the current behaviour, before refactoring them. Ticket: ENT-14276 Signed-off-by: Victor Moene <victor.moene@northern.tech> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 2367056)
FuzzySetMatch() now returns -1 instead of the strncmp() result when a prefix does not match. All callers only compare the result to 0. Ticket: ENT-14276 Signed-off-by: Victor Moene <victor.moene@northern.tech> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 93ecf30)
Ticket: ENT-14276 Signed-off-by: Victor Moene <victor.moene@northern.tech> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 47d645e)
Ticket: ENT-14276 Signed-off-by: Victor Moene <victor.moene@northern.tech> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 9bb2f43)
Ticket: ENT-14276 Signed-off-by: Victor Moene <victor.moene@northern.tech> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 32085e2)
Ticket: ENT-14276 Signed-off-by: Victor Moene <victor.moene@northern.tech> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit faefd14)
FuzzySetMatch() now determines the notation of the pattern (prefix, CIDR or range) and calls the matching helper. Ticket: ENT-14276 Signed-off-by: Victor Moene <victor.moene@northern.tech> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit a35d555)
It now splits host and port first and determines the address type afterwards, instead of doing both in each branch. Ticket: ENT-14276 Signed-off-by: Victor Moene <victor.moene@northern.tech> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit c6e2947)
It was never defined. Ticket: ENT-14276 Signed-off-by: Victor Moene <victor.moene@northern.tech> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 078426a)
Groups without a range, e.g. "fe80", were parsed as decimal, so "fe80:1-3:0:0:0:0:0:1" matched "fe81:2:0:0:0:0:0:1". Changelog: Title Signed-off-by: Victor Moene <victor.moene@northern.tech> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit ec2ff05)
"2001:10-20:0:0:0:0:0:1" did not match "2001:10:0:0:0:0:0:1". Changelog: Title Signed-off-by: Victor Moene <victor.moene@northern.tech> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 473ba52)
Neither in the pattern nor in the address, so "2001:db8:1-5::1" never matched "2001:db8:3::1". Invalid groups are now rejected too. Changelog: Title Signed-off-by: Victor Moene <victor.moene@northern.tech> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit a55c1cc)
…ctet When an octet failed to parse, the value of the previous octet was compared instead, so "10.x.0.1-50" matched "10.10.0.25". Changelog: Title Signed-off-by: Victor Moene <victor.moene@northern.tech> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit bc97da1)
…re now rejected The address was never validated, so an uninitialized address was compared, and e.g. "bogus/0" matched every address. Changelog: Title Signed-off-by: Victor Moene <victor.moene@northern.tech> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit f02295c)
…ranges FuzzyMatchParse() always returned true. It now uses the same parsers as FuzzySetMatch(), including for CIDR patterns. Changelog: Title Signed-off-by: Victor Moene <victor.moene@northern.tech> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit a9c77d4)
FuzzyHostMatch() read before the start of its buffer when the host name was empty or only digits. Only visible with ASan/valgrind. Changelog: Title Signed-off-by: Victor Moene <victor.moene@northern.tech> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 2af3afa)
… digit It contained the host name, e.g. "1password.com", instead of its IP address. ParseHostPort() now uses inet_pton() to detect IPv4. Changelog: Title Ticket: ENT-14276 Signed-off-by: Victor Moene <victor.moene@northern.tech> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 97a0e4e)
There is nothing fuzzy about them. IPRangeMatch() and HostRangeMatch() now return true on match, like StringMatch(), instead of 0. Signed-off-by: Victor Moene <victor.moene@northern.tech> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit acda8ce)
The acl argument is always dereferenced. Signed-off-by: Victor Moene <victor.moene@northern.tech> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit e3d1a36)
Signed-off-by: Victor Moene <victor.moene@northern.tech> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit bc62b2d)
Signed-off-by: Victor Moene <victor.moene@northern.tech> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 2003c09)
… level
E.g. isipinsubnet("10.0.0.0/8", "not-an-ip-address") logged an error.
The same applies to IP lists in cf-serverd, e.g. admit_ips and allowconnects.
Changelog: Commit
Ticket: ENT-14276
Signed-off-by: Victor Moene <victor.moene@northern.tech>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 2e725a0)
|
@cf-bottom Jenkins with exotics please :) |
|
Sure, I triggered a build: (with exotics) Jenkins: https://ci.cfengine.com/job/pr-pipeline/15207/ Packages: http://buildcache.cfengine.com/packages/testing-pr/jenkins-pr-pipeline-15207/ |
|
@cf-bottom selenium please :) |
|
Sure, I triggered a build: [SELENIUM] Jenkins: https://ci.cfengine.com/job/pr-pipeline/15212/ Packages: http://buildcache.cfengine.com/packages/testing-pr/jenkins-pr-pipeline-15212/ |
|
@cf-bottom selenium please :) |
|
Alright, I triggered a build: [SELENIUM] Jenkins: https://ci.cfengine.com/job/pr-pipeline/15214/ Packages: http://buildcache.cfengine.com/packages/testing-pr/jenkins-pr-pipeline-15214/ |
|
@victormlg please follow up on failing selenium test |
|
@cf-bottom selenium please :) |
|
Alright, I triggered a build: [SELENIUM] Jenkins: https://ci.cfengine.com/job/pr-pipeline/15223/ Packages: http://buildcache.cfengine.com/packages/testing-pr/jenkins-pr-pipeline-15223/ |
Backporting: #6485 and the commits it depends on