Repository navigation
fix(containment): restrict additional Linux terminal controls - #240
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.
|
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:
|
|
Superseded by #255, which contains this PR's exact head ( |
Pull request was closed
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. Software-terminal tests cover request denial. The later disposable-console test below proves selection and paste effects with privileged controls; this kernel already blocks ordinary users.
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
Console paste effect validation, November 2 UTC. A fresh disposable ARM64 console guest passed 54 cases: two identities, three filter modes, three upper-bit patterns, and selection-only, paste-only, and combined operations. An outside parent checked exact input bytes or preserved selection after child exit. Privileged unfiltered controls injected a harmless marker; the production filters prevented it. Removing only the
TIOCLINUXcomparison restored the forbidden effect in all nine privileged cases. Filtered ordinary-user input, output, settings, resize/query controls, and outside restoration passed.The guest used Linux
6.12.113-138.209.amzn2023.aarch64, a dummy console, 512 MiB, one CPU, and no network. This kernel already refuses selection and paste to uid 1000 with no effective capabilities. The successful effect control used uid 0 with administrator capability inside the guest; it is not an ordinary-user exploit reproduction or root-launched Box qualification. The guest ran both retained production filters from #255 at3640621, byte-identical at37b44c6, rather than the full Box launcher. ItsTIOCLINUXrule is the restriction introduced by #240. Full launcher evidence remains the separate host runs. No physical keyboard/display, minimum-kernel, or cloud qualification is claimed. Raw evidence is retained in the implementation workspace underevidence/console-paste/.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.Original host environment limits. A real virtual console was unavailable to the host test user. Those pseudoterminal tests proved request denial only. The later disposable-console result above adds direct selection/paste effect evidence with its stated privilege limits. 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.