fix: harden web API pipeline loading and request validation - #18
Merged
shouc merged 1 commit intoApr 25, 2026
Merged
Conversation
7 tasks
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.
Summary
This PR hardens the local web UI/API control plane so browser-reachable requests cannot use the web API to execute arbitrary local pipeline files by path.
application/jsonon/api/runsand/api/runs/validatepipeline_pathon those web API endpoints by defaultAGENTFLOW_API_ALLOW_PIPELINE_PATH=1Security issues covered
pipeline_pathand loaded local.pypipeline filesBefore this PR
/api/runsand/api/runs/validateaccepted requests that suppliedpipeline_pathload_pipeline_from_path(...), which executes.pypipeline files during loadingapplication/jsonon these routesAfter this PR
/api/runsand/api/runs/validatenow reject non-JSON requests with HTTP 415pipeline_pathis disabled for the web API by default and rejected with HTTP 403AGENTFLOW_API_ALLOW_PIPELINE_PATH=1Explicit operator choice
Secure default:
Behavior:
/api/runsand/api/runs/validatepipeline_pathon those browser-facing endpointsExplicit trusted opt-in:
Behavior:
Why this matters
The web UI/API is a local control plane, not an untrusted code-loading surface. Before this patch, a request that could reach the browser-facing API could ask AgentFlow to load a local pipeline file by path, including a
.pypipeline that executes during loading. Requiring JSON and default-disablingpipeline_pathrestores the intended trust boundary for the web API while keeping an explicit opt-in for trusted local workflows.Attack flow
Affected code
pipeline_pathfor web API requestsagentflow/app.py,tests/test_api.pyagentflow/app.py,tests/test_api.pyREADME.md,docs/cli.mdRoot cause
Issue 1: web API path-based pipeline loading
pipeline_pathfield and passed it intoload_pipeline_from_path(...).pypipeline filesIssue 2: missing JSON content-type enforcement
CVSS assessment
pipeline_pathand loaded local.pypipeline filesCVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:HCVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:L/I:L/A:NRationale:
Safe reproduction steps
1. Default-denied
pipeline_pathon the web APIPOST /api/runs/validatewith JSON body{ "pipeline_path": "/path/to/pipeline" }.pipeline_path is disabled for the web API by default.2. JSON-only enforcement
POST /api/runs/validatewith a non-JSONContent-Typesuch astext/plain.application/json content type required.3. Explicit trusted opt-in
AGENTFLOW_API_ALLOW_PIPELINE_PATH=1.POST /api/runs/validatewith JSON body containing a valid localpipeline_path.Expected vulnerable behavior
Changes in this PR
_require_json_request(...)and apply it to/api/runsand/api/runs/validate_api_pipeline_path_enabled()as an explicit opt-in gate_parse_pipeline_payload(...)so web API callers rejectpipeline_pathby default with HTTP 403pipeline_path, explicit opt-in enablement, and non-JSON rejectionREADME.mdanddocs/cli.mdFiles changed
agentflow/app.pypipeline_pathgate for web API routestests/test_api.pyREADME.md,docs/cli.mdMaintainer impact
agentflow/app.py, which should make future refactors easier to keep secureSuggested fix rationale
Reference patterns from other software
Type of change
Test plan
python -m pytest tests/test_api.py -qagentflow/app.pyandagentflow/loader.pyExecuted with:
source /Users/lennon/.hermes/hermes-agent/venv/bin/activate && python -m pytest tests/test_api.py -qgit diff -- README.md agentflow/app.py docs/cli.md tests/test_api.pyNot run:
Disclosure notes
SECURITY.md