Skip to content

fix(rule): harden protected path normalization - #47

Open
ronheichman wants to merge 9 commits into
perplexityai:mainfrom
ronheichman:canonical-path-operand
Open

ronheichman wants to merge 9 commits into
perplexityai:mainfrom
ronheichman:canonical-path-operand

Conversation

@ronheichman

@ronheichman ronheichman commented Aug 28, 2026

Copy link
Copy Markdown

Summary

  • add a lexical canonical_path() CEL helper for separator, dot-segment, Windows drive/UNC, and supported Linux /proc/.../root normalization
  • apply it to the built-in SSH authorized-keys and sudoers rules
  • cover current visudo file, edit, check, and export option forms without adding a generic command-option parser

canonical_path() does not access the filesystem or resolve arbitrary symlinks. Relative paths stay relative, and Windows drive and UNC roots remain distinct. Rule versions and generated checked expressions are updated.

Compound-command enforcement is intentionally left to #46; this PR does not change the enforcement engine. There are no event-schema or dependency changes.

Verification

  • go generate ./rules with no generated diff
  • go test ./...
  • go test -race ./...
  • go vet ./...
  • golangci-lint v2.12.2 run
  • golangci-lint v2.12.2 fmt --diff
  • govulncheck v1.6.0 ./...
  • go mod tidy with no module diff
  • CGO-free Darwin, Linux amd64, and Windows amd64 builds

Expose canonical_path(string) to rules: path.Clean plus a
/proc/<self|thread-self|PID>/root strip, so a rule compares one
normalized target instead of enumerating traversal and proc-root
disguises in bounded regex. Closes the fixed-depth traversal hole a
hand-rolled regex cannot: dir/../ chains resolve at any depth.
@ronheichman
ronheichman force-pushed the canonical-path-operand branch from a9a971c to 41669e2 Compare August 28, 2026 20:31
@ronheichman
ronheichman marked this pull request as ready for review August 29, 2026 02:15
@ronheichman ronheichman changed the title feat(rule): add canonical_path for depth-safe path normalization feat(rule): harden protected paths and compound enforcement Aug 31, 2026
@adel-pplx adel-pplx changed the title feat(rule): harden protected paths and compound enforcement Harden protected-path normalization Sep 15, 2026
@adel-pplx adel-pplx changed the title Harden protected-path normalization fix(rule): harden protected path normalization Sep 15, 2026
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.

2 participants