mirror of
https://github.com/affaan-m/ECC.git
synced 2026-11-23 16:25:30 +00:00
`find . -exec sh -c 'rm -rf {}' \;` was allowed while both `find . -exec rm
{} \;` and a bare `sh -c 'rm -rf ...'` were denied. `isDestructiveFindExec`
classified only the executable named after `-exec`, so a shell wrapper ended
the inspection exactly where the destructive command began. The quote-aware
pass already looks through `sh -c`; this was the sibling that did not.
Two things had to change for that recursion to see the payload:
- `isDestructiveQuoteAware` handed `isDestructiveFindExec` a re-joined
string, which flattened the quoted payload back into separate words. It
now passes the tokens it already holds, through a token-taking half of the
same check.
- `-c` was matched only as a bare token. Short options cluster, so
`sh -ec '<cmd>'`, `sh -xc '<cmd>'`, and `sh -ce '<cmd>'` run the same
string `sh -c '<cmd>'` runs — verified against the shell, as was the fact
that the payload always comes from the next argument (`sh -c'cmd'` is an
invalid option, not an attached value). That gap was reachable without
`find` at all: `sh -ec 'rm -rf /important/data'` was allowed.
`-o`/`-O` take a value, so a `c` behind one of them is that value, and `--`
ends the options. The shell rejects both spellings instead of running the
string, so the scan stops there rather than reporting a deletion that cannot
happen.
Tests cover each spelling in both directions. The two allow-list cases carry
a destructive payload deliberately: with a benign one they pass whether or
not the arity and `--` stops are present, and pin nothing.