-
Notifications
You must be signed in to change notification settings - Fork 466
fix: legacy-security mode installs awf non-rootless, uses plain sudo for log parsing #48098
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Copilot
wants to merge
10
commits into
main
Choose a base branch
from
copilot/legacy-security-enable-emits-sudo-e-awf
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e2a249b
Initial plan
Copilot fc864d6
chore: initial plan
Copilot 70734cf
fix: legacy-security mode installs awf non-rootless and uses plain su…
Copilot 4d83086
docs: add draft ADR-48098 for legacy-security AWF non-rootless install
github-actions[bot] 3451fba
chore: start pr-finisher pass
Copilot ad0355d
Merge branch 'main' into copilot/legacy-security-enable-emits-sudo-e-awf
github-actions[bot] 038df24
Merge branch 'main' into copilot/legacy-security-enable-emits-sudo-e-awf
github-actions[bot] 977cf85
Merge branch 'main' into copilot/legacy-security-enable-emits-sudo-e-awf
pelikhan bb2db96
fix: simplify legacy-security rootless guards
Copilot 4bb0af6
Merge origin/main into conflict-resolution branch
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
43 changes: 43 additions & 0 deletions
43
docs/adr/48098-legacy-security-awf-install-non-rootless.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| # ADR-48098: Legacy-Security Mode Installs AWF to Non-Rootless Path | ||
|
|
||
| **Date**: 2026-07-26 | ||
| **Status**: Draft | ||
| **Deciders**: Unknown | ||
|
|
||
| --- | ||
|
|
||
| ### Context | ||
|
|
||
| The AWF binary can be installed in two modes: **rootless** (`--rootless`), which places the binary in `~/.local/bin` to minimize privilege surface when `NetworkIsolation` is true; or **non-rootless**, which installs to `/usr/local/bin` for system-wide access. The `legacy-security: enable` sandbox option causes generated workflow steps to invoke AWF as `sudo -E awf`. The `sudo` command enforces its own `secure_path`, which includes `/usr/local/bin` but not `~/.local/bin`. When both `NetworkIsolation` and `LegacySecurity` were true, AWF was installed rootless (`~/.local/bin`) but invoked via `sudo -E awf`, causing `sudo: awf: command not found` at agent startup. The `print_firewall_logs.sh` step had the identical flaw: it conditionally passed `--rootless` based solely on `NetworkIsolation`, ignoring that legacy-security mode grants full sudo access. | ||
|
|
||
| ### Decision | ||
|
|
||
| We will skip the `--rootless` install flag whenever `AgentSandboxConfig.LegacySecurity` is true, regardless of the `NetworkIsolation` setting. The condition in `generateAWFInstallationStep` becomes `NetworkIsolation && !Disabled && !LegacySecurity`, and `generateFirewallLogParsingStep` adds the same `!LegacySecurity` guard. This ensures AWF lands in `/usr/local/bin` (on `sudo`'s `secure_path`) in legacy-security mode, making `sudo -E awf` resolvable. | ||
|
|
||
| ### Alternatives Considered | ||
|
|
||
| #### Alternative 1: Extend sudo's secure_path to include ~/.local/bin | ||
|
|
||
| Runner provisioning could be modified to add `~/.local/bin` to `sudo`'s `secure_path` via `/etc/sudoers.d/`. This would allow rootless installs to coexist with sudo invocations. However, this requires infrastructure changes outside this codebase's control, and broadening `secure_path` on shared runners increases the attack surface for privilege escalation via user-writable directories. | ||
|
|
||
| #### Alternative 2: Invoke AWF as `sudo -E env PATH=$PATH awf` | ||
|
|
||
| The generated sudo invocation could preserve the full user `PATH` using `sudo -E env PATH=$PATH awf`, avoiding the `secure_path` restriction without changing the install location. This would be a more invasive change touching the AWF invocation pattern across multiple generated steps, increasing regression risk for non-legacy-security paths that already work correctly. | ||
|
|
||
| ### Consequences | ||
|
|
||
| #### Positive | ||
| - Agent startup no longer fails with `sudo: awf: command not found` in legacy-security mode with network isolation enabled. | ||
| - The firewall log parsing step now uses the correct sudo invocation mode, consistent with the AWF install path. | ||
|
|
||
| #### Negative | ||
| - AWF is installed to a root-owned directory (`/usr/local/bin`) in legacy-security mode, requiring the install script to run with elevated privileges (this is already the behavior for non-rootless installs). | ||
| - The condition `NetworkIsolation && !LegacySecurity` is a compound flag interaction; future maintainers changing either flag's semantics must account for this coupling. | ||
|
|
||
| #### Neutral | ||
| - The smoke-service-ports lock file is regenerated to drop the now-incorrect `--rootless` flags, keeping the file consistent with updated compiler behavior. | ||
| - Tests explicitly cover the `LegacySecurity=true` + `NetworkIsolation=true` combination for both the install step and the log parsing step, providing a regression guard. | ||
|
|
||
| --- | ||
|
|
||
| *ADR created by [adr-writer agent]. Review and finalize before changing status from Draft to Accepted.* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.