T09 · Insecure Skill Coding Practices
- Location
scripts/gh_workflow.py:90- Finding
Repository write operation does not enforce the documented confirmation gate
- Content
View full analysis
Vulnerability Details
File Location:
scripts/gh_workflow.py, lines 90–163
Vulnerability Type: Unenforced authorization and confirmation gate for remote repository mutation
Risk Level: MediumVulnerable Code
python def cmd_push_file(a): with open(a.path, "rb") as f: content_b64 = base64.b64encode(f.read()).decode("ascii") remote_path = a.repo_path or os.path.basename(a.path) # 1. blob blob = call("POST", "/repos/%s/git/blobs" % a.repo, {"content": content_b64, "encoding": "base64"}, a.dry_run) if a.dry_run: print("would push %s -> %s:%s (branch=%s)" % (a.path, a.repo, remote_path, a.branch)) return blob_sha = blob["sha"] # 2. current branch tip ref = call("GET", "/repos/%s/git/refs/heads/%s" % (a.repo, a.branch)) commit_sha = ref["object"]["sha"] # 3. current tree cur = call("GET", "/repos/%s/git/commits/%s" % (a.repo, commit_sha)) tree_sha = cur["tree"]["sha"] # 4. new tree new_tree = call("POST", "/repos/%s/git/trees" % a.repo, {"base_tree": tree_sha, "tree": [{"path": remote_path, "mode": "100644", "type": "blob", "sha": blob_sha}]}) # 5. new commit new_commit = call("POST", "/repos/%s/git/commits" % a.repo, {"message": a.message, "tree": new_tree["sha"], "parents": [commit_sha]}) # 6. move ref call("PATCH", "/repos/%s/git/refs/heads/%s" % (a.repo, a.branch), {"sha": new_commit["sha"], "force": False}) print("pushed %s -> %s:%s commit=%s" % (a.path, a.repo, remote_path, new_commit["sha"][:8]))python pf = sub.add_parser("push-file") pf.add_argument("--repo", required=True) pf.add_argument("--path", required=True, help="local file to upload") pf.add_argument("--repo-path", help="remote path (default: local basename)") ...[truncated 2773 chars]- Remediation
View remediation
Remediation Suggestions
- Make
push-filedry-run by default and require an explicit apply option for the mutating phase. - Require a write-specific authorization flag such as
--confirm-writerather than treating the absence of--dry-runas authorization. - Bind confirmation to the exact repository, branch, remote path, local path, and commit message. For example, print a normalized operation summary and require a confirmation token derived from that summary.
- For interactive use, prompt the user to approve the normalized target immediately before the first POST request. Provide a separate explicit non-interactive confirmation mechanism for CI environments.
- Apply the gate before uploading the blob so that no remote Git objects are created before authorization.
- Preserve
force=Falseand consider adding branch or repository allowlists where the Skill is deployed in an automated Agent environment.
- Make
