Skip to content

fix(file-source): [OBE-12847] add symlink_policy to control symlink following - #185

Open
JuanMantica45 wants to merge 1 commit into
Sentinel-One:masterfrom
JuanMantica45:fix/obe-12847-file-symlink-policy
Open

JuanMantica45 wants to merge 1 commit into
Sentinel-One:masterfrom
JuanMantica45:fix/obe-12847-file-symlink-policy

Conversation

@JuanMantica45

Copy link
Copy Markdown
Contributor

Summary

  • The file source followed symlinks unconditionally, so a low-privilege user with write access to a globbed directory could ln -s /etc/shadow x.log and have Vector (often root) ship the contents to a sink.
  • Adds symlink_policy on the file source: follow (default, unchanged behavior), deny (skip symlinks), within_root (follow only if the real path stays under the include pattern's literal directory prefix).
  • All file opens (FileWatcher::new, update_path, 5 fingerprinter opens) go through one SymlinkPolicy::open helper using O_NOFOLLOW on unix for deny/within_root, so a swap after the glob check fails closed.
  • Default stays follow because k8s log paths (/var/log/containers/*.log) are symlinks; kubernetes_logs is hardcoded to Follow. Opting in (e.g. Observo-generated file configs using within_root) is a follow-up template change.
  • Docs: exclude matches the symlink path, not its target. Cue reference hand-edited (not regenerated) and changelog fragment added.

Known limits

  • within_root: a parent directory swapped into a symlink between the glob check and the open is not covered; O_NOFOLLOW only guards the final component.
  • Rejected paths emit emit_path_globbing_failed every glob cycle (~1s default); I did not check whether that event is rate-limited.
  • Non-unix fallback (symlink_metadata check) is untested.

Test plan

  • cargo test -p file-source (25 pass), incl. open-policy and glob policy tests; existing fingerprint/checkpoint tests unchanged
  • cargo test --lib --no-default-features --features sources-file sources::file (34 pass), incl. end-to-end follow/deny/within_root tests
  • cargo check --lib --no-default-features --features sources-kubernetes_logs
  • Tests were written alongside the implementation, not run red-first

Jira: OBE-12847

🤖 Generated with Claude Code

…ollowing

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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