Repository navigation
fix(containment): restrict additional Linux terminal controls - #240
Open
kevin-orellana wants to merge 2 commits into
Open
kevin-orellana wants to merge 2 commits into
kevin-orellana wants to merge 2 commits into
Conversation
## Problem The inherited terminal remains a host resource. The existing TIOCSTI refusal leaves console controls and line-discipline changes reachable from an untrusted workload. The baseline terminal_discipline_cannot_change_or_break_input test demonstrates that TIOCSETD can replace terminal input processing. ## Solution Refuse TIOCLINUX and TIOCSETD beside TIOCSTI in the existing deny-only filter. Compare the low 32 request bits, as the kernel does. Keep ordinary terminal operations permitted. Document the restricted requests and remaining terminal limits. No public API or policy grant changes. ## Tests The containment suite passes 553 tests with all features. The five added tests cover truncated request arguments, unchanged terminal discipline and input queue, normal terminal operations, and foreground interrupts. Baseline and separate TIOCLINUX/TIOCSETD removal controls fail the relevant denial tests. Successful-operation controls pass on both baseline and repaired builds. A disposable full-CLI harness passes 17 scenarios, including input/output, resizing, interrupts, and restoration. Native validation uses ARM64 Amazon Linux 2023 and kernel 6.12.111. A real virtual console is unavailable; this does not claim console effect coverage, full terminal isolation, or cloud qualification.
kevin-orellana
marked this pull request as ready for review
October 30, 2026 18:09
kevin-orellana
enabled auto-merge (squash)
October 30, 2026 18:15
|
Assessment: Comment The filter change is correct for the PTY case, which is the common one, and I found no blocking defect. My one substantive finding is about scope: on a Linux virtual console, some console controls are still reachable, and the agent guidance does not record this residual. Review Categories
Checked and held:
The disposable-terminal tests that compare against an unfiltered baseline are strong evidence for this fix. |
|
Assessment: Approve I re-reviewed at Re-verified at this commit
Checked and held:
|
8 tasks done
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Human readable section
Problem. An untrusted program can share the operator's terminal and interfere with its input. Box already blocks one way to inject input. It still permits Linux console paste requests and changes to the terminal's input processing.
Solution. Block those two additional requests. In the disposable-terminal test, the original code lets the program disable input processing. With this change, input continues to work. Tests also retain input/output, terminal settings, window sizing, and Ctrl+C behavior.
Trade-off. Programs that need these requests receive a permission error. Other Linux text-console controls remain available, including keyboard and display mode changes. This change does not fully isolate a shared terminal. Tests confirm request denial through a software terminal, but do not reproduce selection or paste on a real Linux text console.
Description
Extend the request restrictions added in #126 with
TIOCLINUXandTIOCSETD. KeepTIOCSTIrestricted. Compare each request's low 32 bits, matching Linux argument handling.TIOCLINUXincludes console selection and paste operations. The filter checks argument values, but cannot read the subcommand through its pointer. It therefore blocks everyTIOCLINUXsubcommand. A line discipline is the kernel component that processes terminal input.TIOCSETDreplaces that component. Neither request is needed by the ordinary interactive controls exercised here.Upstream Linux 6.12 permits
KDSKBMODE,KDSETMODE,VT_SETMODE, andVT_ACTIVATEwhen the descriptor is the caller's controlling terminal.KDSKBMETAhas no equivalent permission check in its dispatch branch. These requests remain outside this PR's restricted set. This is a source-confirmed residual risk; its effects were not reproduced on a real console here. See the kernel dispatch and keyboard mode handling.The disposable-terminal test checks effects outside the untrusted program. The original code lets the program change the shared input processor to
N_NULL, which breaks input. With the fix, the outside observer sees the original input processor and working input.Five terminal tests cover requests with nonzero upper 32 bits, unchanged input processing and queued input, normal terminal operations, and foreground interrupts. They consolidate the two older terminal tests, preserve their pixel-size and filtered-settings assertions, and share one fork harness. Removing either added restriction makes the corresponding denial tests fail. The successful-operation controls also pass on the baseline.
Authored and reviewed with Codex assistance.
Related Issues
Related to #51. Extends #126. This does not close the broader issue.
Follow-up #253 tracks the remaining virtual-console restrictions and their required validation.
Type of Change
Bug fix
Testing
Current hosted checks. The continuous integration gate passed for
c47b6bd2c1dcb498b5a675e129cb237df9892667on November 1, 2026. This status is separate from the local and historical test results below. The optional Verdict job skipped and provides no coverage.Validation covers the source committed as
c47b6bd2c1dcb498b5a675e129cb237df9892667, withEXPERIMENTAL_LINUX_SUPPORT=TRUEon native ARM64 Amazon Linux 2023, kernel6.12.113-138.209.amzn2023.aarch64.GREEN. Its older console characterization note is not terminal-denial evidence.just clippy; strict containment lint needed none.justitself is unavailable on the host.At the earlier
16ea76drevision, the disposable full-CLI terminal harness passed 17 scenarios, including 12 request denials, input/output, raw-mode restoration, window queries/resizing, and Ctrl+C with foreground restoration. Baseline and separate restriction-removal controls detected both added denials, including requests with nonzero upper 32 bits. Four moved test bodies remain byte-identical; the current follow-up changes only the normal-operation assertions and shared harness, plus a private production-helper name. These earlier removal runs were not repeated or presented as new runs. The first historical workspace attempt omitted the Linux opt-in and failed at startup; corrected runs passed.Environment limits. A real virtual console is unavailable to the test user. Pseudoterminal tests prove that console requests are denied, but cannot reproduce actual console selection/paste. The host kernel already disables legacy
TIOCSTI; invalid-descriptor comparisons separately attribute refusal to the filter. The example runner found no scripted examples. No live SDK tutorial, minimum-kernel, root, macOS, or cloud-qualification run was performed locally. Hosted platform checks remain separate evidence.just check, orcargo test --workspace --all-features)cargo fmt --allandcargo clippy --workspace --all-targets --all-features -- -D warningsThe workspace lint command included the vendored-code allowances from the documented
just clippyrecipe. The host lacksjust, so the equivalent commands ran directly. Strict containment lint used no allowances.Checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.