Repository navigation
CmdSequencer, FpySequencer: add optional file sandbox - #6299
Conversation
FileUplink, FileDownlink, FileManager and PrmDb can restrict their file access to a directory, but the sequencers opened any path a command or port supplied. A deployment that configures restricted sandboxes still had sequence loads, and FpySequencer's DUMP_STACK_TO_FILE write, outside them. - CmdSequencer::configureSandbox(directory): every sequence load (CS_VALIDATE, CS_RUN, seqRunIn, seqDispatchIn, loadSequence) whose file name resolves outside the directory is rejected with CS_FileOutsideSandbox before the file is opened. The check is in loadFile, so it applies to every sequence format, including a custom one set with setSequenceFormat. - FpySequencer::configureSandbox(directory): the same check for sequence validation reads and DUMP_STACK_TO_FILE output files, with a new FileOutsideSandbox event (appended so existing event IDs are kept). - Until configureSandbox is called, any path is allowed, so existing deployments are unchanged. - Unit tests for paths inside, outside and escaping via "..", for both sequence formats and the stack dump; SDD sections for both components. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Coverage report — base
|
| Module | Line | Δ | Function | Δ | Branch | Δ |
|---|---|---|---|---|---|---|
Svc/FpySequencer |
87.04 | +0.12 | 99.09 | +0.01 | 79.32 | +0.16 |
Svc/CmdSequencer |
93.62 | +0.15 | 98.17 | +0.04 | 84.17 | +0.30 |
Fw/DataStructures |
97.87 | +0.80 | 97.14 | +0.00 | 82.48 | +1.28 |
New modules
| Module | Line | Function | Branch |
|---|---|---|---|
Fw/Prm |
0.00 | 0.00 | 0.00 |
Modules without UTs
CFDP/Checksum/GTest, Drv/LinuxGpioDriver, Drv/LinuxI2cDriver, Drv/LinuxSpiDriver, Drv/Ports/DataTypes, Drv/PosixUartDriver, FppTestProject/FppTest/topology/async, FppTestProject/FppTest/topology/components/Comp, FppTestProject/FppTest/topology/components/Framework, FppTestProject/FppTest/topology/components/Receiver, FppTestProject/FppTest/topology/components/Sender, FppTestProject/FppTest/topology/guarded, FppTestProject/FppTest/topology/sync, FppTestProject/FppTest/topology/top_ports, FppTestProject/FppTest/topology/types, Fw/Com, Fw/Comp, Fw/FilePacket/GTest, Fw/Fpy, Fw/Obj, Fw/Port, Fw/Sm, Fw/Test, Fw/Types/GTest, Os/Models, Svc/Ccsds/Types, Svc/Ccsds/Utils, Svc/FatalHandler, Svc/Subtopologies/CdhCore, Svc/Subtopologies/ComCcsds, Svc/Subtopologies/ComCcsdsSdls, Svc/Subtopologies/ComFprime, Svc/Subtopologies/ComLoggerTee, Svc/Subtopologies/DataProducts, Svc/Subtopologies/DpCompression, Svc/Subtopologies/FileHandling, Svc/Subtopologies/FileHandlingCfdp, Svc/Subtopologies/FileHandlingCfdp/FileHandlingCfdpConfig, TestDeploymentsProject/Ref/DpDemo, TestDeploymentsProject/Ref/PingReceiver, TestDeploymentsProject/Ref/RecvBuffApp, TestDeploymentsProject/Ref/SendBuffApp, TestDeploymentsProject/Ref/Top, TestDeploymentsProject/Ref/TypeDemo, cmake/test/data/TestConfigDeployment, cmake/test/data/TestDeployment/TestBuildAutocoder, cmake/test/data/TestDeployment/TestDuplicateDirective, cmake/test/data/TestDeployment/TestHeaderAutocoder, cmake/test/data/TestDeployment/TestLinkDepends, cmake/test/data/TestDeployment/TestRelative, cmake/test/data/test-fprime-library/TestLibrary/TestComponent, cmake/test/data/test-fprime-library2/TestLibrary2/TestComponent
|
Thanks @bitWarrior for the super fast turnaround on this and for extending Reviewed the changes in |
|
@bitWarrior please make sure to add me as a reviewer on PRs that touch FpySequencer |
|
Thank you @bitWarrior, @LeStarch, and Quick follow-up question regarding the advisory lifecycle:
Thank you again for the rapid triage and collaboration! |
Change Description
CmdSequencer::configureSandbox(directory): a sequence load whose file name resolves outside the directory is rejected with the newCS_FileOutsideSandboxevent before the file is opened, and the command respondsEXECUTION_ERROR. This coversCS_VALIDATE,CS_RUN,seqRunIn,seqDispatchInandloadSequence. The check is inCmdSequencerImpl::loadFile, so it applies to every sequence format: F´, AMPCS (including its.CRC32companion file), and any format set withsetSequenceFormat.FpySequencer::configureSandbox(directory): the same check for sequence reads invalidate()(RUN,RUN_ARGS,VALIDATE,VALIDATE_ARGS,seqRunIn) and for theDUMP_STACK_TO_FILEoutput file. Rejections log the newFileOutsideSandboxevent. The event is appended at the end ofFpySequencerEvents.fppiso that existing auto-assigned event IDs do not change.configureSandbox()is called, any path is allowed, so existing deployments behave the same.Rationale
FileUplink, FileDownlink, FileManager and PrmDb can be restricted to a directory, but the sequencers opened whatever path a command or port supplied. A deployment that configured restricted sandboxes still had sequence loads, and FpySequencer's stack-dump write, outside them. This closes that gap using the same
Os::FilePathUtilsresolve-and-contain check that FileManager uses.Testing/Review Recommendations
Immediate.SandboxandImmediate.SandboxAMPCS. They check that a load inside the sandbox succeeds, thatCS_VALIDATEandCS_RUNoutside the sandbox are rejected, and that..traversal is rejected.validate_sandboxchecks the same cases.cmd_DUMP_STACK_TO_FILE_sandboxchecks that a dump to../is rejected and the file is not created, and that a dump inside the sandbox still succeeds.fprime-util check: CmdSequencer 97/97 and FpySequencer 340/340 pass./tmp.Os::SandboxedFile, path checks are textual and do not follow symlinks.Future Work
configureSandboxonce its integration-test sequences live inside the sandbox directory.Contributor Checklist
AI Usage (see policy)
Claude Code (Claude Opus 5.5) was used for the analysis, the code changes, the unit tests and the SDD updates, under the contributor's direction. The contributor chose the design (opt-in default, coverage of both sequencers) and reviewed the changes.
AGENTS.md).🤖 Generated with Claude Code