T09 · Insecure Skill Coding Practices
- Location
scripts/sync.py:69- Finding
Notion API Token Exposed Through Process Command-Line Arguments
- Content
View full analysis
dict: headers = [ "-H", f"Authorization: Bearer {CONFIG['NOTION_KEY']}", "-H", "Notion-Version: 2026-03-11", "-H", "Content-Type: application/json" ] cmd = ["curl", "-s", "-X", "POST", url, "-d", json.dumps(payload)] + headers return json.loads(subprocess.run(cmd, capture_output=True, text=True).stdout) def notion_patch(url: str, payload: dict) -> dict: headers = [ "-H", f"Authorization: Bearer {CONFIG['NOTION_KEY']}", "-H", "Notion-Version: 2026-03-11", "-H", "Content-Type: application/json" ] cmd = ["curl", "-s", "-X", "PATCH", url, "-d", json.dumps(payload)] + headers return json.loads(subprocess.run(cmd, capture_output=True, text=True).stdout) ``` ### Technical Analysis Both HTTP helper functions place the Notion bearer token directly in the argument vector of a spawned `curl` process. Although `subprocess.run` uses an argument list and therefore does not introduce shell-command injection, the full authorization header can be visible through operating-system process inspection facilities while `curl` is running. Depending on the host configuration, local users, monitoring agents, debugging tools, audit systems, process collectors, or privileged container peers may be able to record the command line. Environment-based loading of `NOTION_API_KEY` does not prevent this exposure because the secret is subsequently copied into the child process arguments. ### Attack Path 1. A legitimate user configures `NOTION_API_KEY` and runs the synchronization script. 2. The script starts `curl` with `Authorization: Bearer ` in its command-line arguments. 3. An attacker with sufficient local process-observation access monitors proces ...[truncated 1263 chars]- Remediation
View remediation
dict: body = json.dumps(payload).encode("utf-8") request = urllib.request.Request( url, data=body, method=method, headers={ "Authorization": f"Bearer {CONFIG['NOTION_KEY']}", "Notion-Version": "2026-03-11", "Content-Type": "application/json", }, ) with urllib.request.urlopen(request, timeout=30) as response: return json.loads(response.read().decode("utf-8")) ``` The application must also handle non-success HTTP responses without including the authorization header in diagnostic output. ]]>
