T09 · Insecure Skill Coding Practices
- Location
scripts/moltbook_post.sh:47- Finding
Bearer API Token Exposed in Terminal and Log Output
- Content
View full analysis
Vulnerability Details
File Location:
scripts/moltbook_post.sh, lines 47-51
Vulnerability Type: Sensitive credential disclosure through standard output
Risk Level: MediumVulnerable Code
bash echo " curl -X POST https://www.moltbook.com/api/v1/verify \\" echo " -H \"Authorization: Bearer $API_KEY\" \\" echo " -H \"Content-Type: application/json\" \\" echo " -d '{\"verification_code\": \"$verify_code\", \"answer\": \"YOUR_ANSWER\"}'"Technical Analysis
The script interpolates
MOLTBOOK_API_KEYinto a command printed to standard output. Although the token is intentionally supplied through an environment variable rather than hardcoded, printing it defeats that protection.Standard output may be retained in shell scrollback, CI/CD logs, agent conversation transcripts, terminal recordings, monitoring systems, or redirected output files. Anyone who can read those records can recover the bearer token without needing direct access to the original process environment.
The behavior is unnecessary for the declared posting and verification functionality. The script can display a command containing the literal environment-variable reference or perform the verification request itself without disclosing the secret.
Attack Path
- A user configures a valid
MOLTBOOK_API_KEYand invokes the posting script. - Moltbook returns a response containing a verification challenge.
- The script enters the verification branch and expands
$API_KEYinto the displayedcurlcommand. - The output is captured by an agent transcript, CI log, terminal logger, redirected output file, or another log collection mechanism.
- An attacker with access to that retained output extracts the bearer token.
- The attacker sends authenticated requests to Moltbook using the stolen credential.
Impact Assessment
The attacker obtains the privileges assigned to the compromised Moltbook API token. Based ...[truncated 419 chars]
- A user configures a valid
- Remediation
View remediation
Remediation Suggestions
-
Never print the expanded bearer token to standard output.
-
If a manual verification command must be displayed, preserve the variable reference literally:
bash echo ' curl -X POST https://www.moltbook.com/api/v1/verify \' echo ' -H "Authorization: Bearer $MOLTBOOK_API_KEY" \' echo ' -H "Content-Type: application/json" \' printf ' --data %q\n' "$verification_payload" -
Prefer implementing verification inside the script so credentials never need to appear in generated instructions.
-
Document that the API key must not be passed on the command line or written to logs.
-
Rotate any API token that may already have appeared in retained output.
-
Configure CI and automation platforms to mask
MOLTBOOK_API_KEY, while treating masking as defense in depth rather than as a substitute for removing the disclosure.
-
