security: validate env-controlled inputs + harden release pipeline (PER-8514–8518)#209
Open
Shivanshu-07 wants to merge 1 commit into
Open
security: validate env-controlled inputs + harden release pipeline (PER-8514–8518)#209Shivanshu-07 wants to merge 1 commit into
Shivanshu-07 wants to merge 1 commit into
Conversation
…ER-8514–8518) Resolves five High-severity AppSec findings (and the C-003..C-006 attack chains built on them): PER-8516 (CWE-306) & PER-8518 (CWE-918) — PERCY_CLI_API was used verbatim as the target for credential-bearing POSTs (capabilities can carry the BrowserStack accessKey) and healthcheck GETs, enabling SSRF and credential exfiltration to an attacker-controlled host. Add _resolve_cli_api_address(): loopback-only by default; a remote host is allowed only over HTTPS with an explicit PERCY_ALLOW_REMOTE_CLI_API opt-in. Otherwise we warn and fall back to http://localhost:5338. PER-8517 (CWE-22) — PERCY_TMP_DIR was passed straight to Path().mkdir() and tempfile.mkstemp(), allowing arbitrary file writes via path traversal. Add _resolve_tmp_dir(): realpath the value and require it to stay within an approved temp root (system tmpdir, /tmp, /var/tmp); fall back to mkdtemp() otherwise. PER-8514 (CWE-829) — release.yml pinned actions to mutable tags and ran with write-all GITHUB_TOKEN. Pin checkout/setup-python/cache to commit SHAs and add permissions: contents: read. PER-8515 (CWE-829) — twine was unpinned in development.txt, allowing a publishing-tool substitution. Pin to twine==5.1.1. Adds unit tests for both validators. Full suite: 140 passing; pylint 10/10. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
Resolves five High-severity AppSec findings (deadline 2026-06-15) in
@percy/appium-python. These five also form the basis of the C-003…C-006 attack chains (PER-8532–8535), which collapse once the components are fixed.PERCY_TMP_DIR→ arbitrary file writetwineenables publishing-tool substitutionChanges
percy/lib/cli_wrapper.py(PER-8516 + PER-8518):PERCY_CLI_APIwas interpolated directly intorequests.get/posttargets. Becausepost_poa_screenshotsforwardscapabilities(which may carry the BrowserStackaccessKey), a hostile value enabled both SSRF and credential exfiltration. Added_resolve_cli_api_address():localhost/127.0.0.1/::1) allowed over http (the normal case);https://and withPERCY_ALLOW_REMOTE_CLI_API=true;http://localhost:5338.percy/providers/generic_provider.py(PER-8517):PERCY_TMP_DIRflowed straight intoPath().mkdir()/tempfile.mkstemp(). Added_resolve_tmp_dir()whichrealpaths the value and requires it to stay within an approved temp root (system tmpdir,/tmp,/var/tmp); otherwise it falls back tomkdtemp()..github/workflows/release.yml(PER-8514): SHA-pinnedactions/checkout,actions/setup-python,actions/cache; addedpermissions: contents: read.development.txt(PER-8515): pinnedtwine==5.1.1.Verification
..rejection).python -m unittest discover).pylinton both changed modules: 10.00/10.release.ymlparses cleanly.Closes PER-8514, PER-8515, PER-8516, PER-8517, PER-8518. Mitigates PER-8532, PER-8533, PER-8534*, PER-8535* (chains).
🤖 Generated with Claude Code