security: use absolute paths for exec to prevent PATH poisoning [2/5]#170
security: use absolute paths for exec to prevent PATH poisoning [2/5]#170
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (8)
✅ Files skipped from review due to trivial changes (4)
🚧 Files skipped from review as they are similar to previous changes (4)
📝 WalkthroughWalkthroughCall sites now resolve executables via a centralized Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 6e872ef9-5c2e-41b8-b15d-90ba30856229
📒 Files selected for processing (8)
internal/attestation/attestation.gointernal/attestation/attestation_test.gothird_party/fleet-intelligence-sdk/pkg/file/file.gothird_party/fleet-intelligence-sdk/pkg/file/file_test.gothird_party/fleet-intelligence-sdk/pkg/host/virtualization_environment.gothird_party/fleet-intelligence-sdk/pkg/process/options.gothird_party/fleet-intelligence-sdk/pkg/process/pids.gothird_party/fleet-intelligence-sdk/pkg/systemd/systemd.go
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9bcd328050
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
9bcd328 to
aeaf471
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@third_party/fleet-intelligence-sdk/pkg/host/virtualization_environment.go`:
- Around line 100-103: The code currently swallows failures from
file.LocateExecutable("sudo") by returning ("", nil); change this to propagate
the error (return "", err) or implement a fallback that attempts to run
dmidecodePath without sudo when sudo isn't found. Locate the sudoPath resolution
(file.LocateExecutable("sudo") and variable sudoPath) and either return the
discovered error instead of nil or add logic that, on sudo resolution failure,
tries the dmidecodePath execution path (using dmidecodePath) and logs the
failure to locate sudo (via the existing logger) before falling back so
detection doesn't silently degrade.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 1fa729d6-2097-4274-a8c1-8def805aa28a
📒 Files selected for processing (8)
internal/attestation/attestation.gointernal/attestation/attestation_test.gothird_party/fleet-intelligence-sdk/pkg/file/file.gothird_party/fleet-intelligence-sdk/pkg/file/file_test.gothird_party/fleet-intelligence-sdk/pkg/host/virtualization_environment.gothird_party/fleet-intelligence-sdk/pkg/process/options.gothird_party/fleet-intelligence-sdk/pkg/process/pids.gothird_party/fleet-intelligence-sdk/pkg/systemd/systemd.go
✅ Files skipped from review due to trivial changes (2)
- third_party/fleet-intelligence-sdk/pkg/process/options.go
- internal/attestation/attestation.go
🚧 Files skipped from review as they are similar to previous changes (4)
- third_party/fleet-intelligence-sdk/pkg/systemd/systemd.go
- third_party/fleet-intelligence-sdk/pkg/file/file.go
- internal/attestation/attestation_test.go
- third_party/fleet-intelligence-sdk/pkg/file/file_test.go
aeaf471 to
cc2c7af
Compare
LocateExecutable relied on exec.LookPath which could return a relative path if "." is in PATH. When the agent runs as root, a local attacker who places a malicious binary in the working directory could hijack execution. Harden LocateExecutable to resolve the result to an absolute path via filepath.Abs before returning it. Also resolve "sudo" through LocateExecutable in GetSystemManufacturer instead of using a bare command name, so the same absolute-path guarantee applies. Signed-off-by: Rodrigo Sampaio Vaz <rvaz@nvidia.com>
cc2c7af to
9515c22
Compare
LocateExecutable relied on exec.LookPath which could return a relative path if "." is in PATH. When the agent runs as root, a local attacker who places a malicious binary in the working directory could hijack execution.
Harden LocateExecutable to resolve the result to an absolute path via filepath.Abs before returning it. Also resolve "sudo" through LocateExecutable in GetSystemManufacturer instead of using a bare command name, so the same absolute-path guarantee applies.
Description
Checklist
Summary by CodeRabbit
Bug Fixes
Tests