Skip to content

fix match-all always matching on string rule attributes - #704

Open
Bountybette wants to merge 1 commit into
USBGuard:mainfrom
Bountybette:match-all-string-attributes
Open

Bountybette wants to merge 1 commit into
USBGuard:mainfrom
Bountybette:match-all-string-attributes

Conversation

@Bountybette

Copy link
Copy Markdown

The match-all set operator added in 1.0.0 is evaluated by setSolveMatchAll in Rule.hpp, which calls Predicates::isSupersetOf for every rule value. Only USBDeviceID and USBInterfaceType specialize that predicate. The generic template was left as a stub that logs "Not implemented" and returns true, and it is what all the std::string attributes go through: name, serial, hash, parent-hash, via-port and with-connect-type. So a rule like allow via-port match-all { "1-1" "1-2" } or allow hash match-all { "..." "..." } authorizes any device on any port with any descriptors, which silently turns a restrictive allow rule into a wildcard. I noticed it from the (E) Not implemented lines in the log while testing rule evaluation, and the new unit test in test_Rule.cpp fails on main (allow name match-all { "Disk" "Mouse" } applies to a device named "Keyboard"). For a single-valued attribute, superset reduces to equality, so the generic isSupersetOf now mirrors the generic isSubsetOf; the two existing specializations are unchanged and make check passes.

The match-all set operator is solved with Predicates::isSupersetOf,
which is only specialized for USBDeviceID and USBInterfaceType. The
generic template was a stub that returned true, so match-all on name,
serial, hash, parent-hash, via-port and with-connect-type matched any
device. Implement it as equality, like the generic isSubsetOf.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant