T09 · Insecure Skill Coding Practices
- Location
SKILL.md:21- Finding
Notion API Token Stored Without Explicitly Restrictive File Permissions
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 21–22
Vulnerability Type: Plaintext credential storage with insecure default permissions
Risk Level: MediumVulnerable Code:
bash mkdir -p ~/.config/notion echo "ntn_your_key_here" > ~/.config/notion/api_keyTechnical Analysis
The setup instructions write the Notion API token to a plaintext file without explicitly restricting the permissions of either the configuration directory or the credential file. The resulting permissions depend on the user's current
umask. With a commonly usedumaskof022, the file can be created with mode0644, making it readable by other local users.The use of
echomay also expose the credential through shell history when a user replaces the placeholder directly in the command. Although no actual token is hardcoded in the project, the documented credential-handling procedure can cause a real token to be stored or recorded insecurely.Attack Path
- A user follows the documented setup procedure and substitutes a valid Notion integration token for the placeholder.
- The shell creates
~/.config/notion/api_keyaccording to the user's defaultumask, potentially with mode0644. - Another local user or a compromised process running under an account that can read the file retrieves the token.
- The attacker submits authenticated requests to
https://api.notion.com/v1/using the stolen bearer token. - The attacker reads or modifies pages, blocks, and data sources that have been shared with the compromised Notion integration.
An additional exposure path exists if the user enters the token directly into an interactive shell command and the command is retained in shell history.
Impact Assessment
Successful exploitation discloses the Notion integration credential. The attacker obtains the same API privileges as the integration, limited to the Notion resources shared with it and the capab ...[truncated 542 chars]
- Remediation
View remediation
Remediation Suggestions
Create the configuration directory and token file with explicit owner-only permissions:
bash install -d -m 700 ~/.config/notion umask 077 printf '%s\n' "ntn_your_key_here" > ~/.config/notion/api_key chmod 600 ~/.config/notion/api_keyAdditional hardening measures:
- Prefer an operating-system credential manager or dedicated secret-management service instead of a plaintext file.
- If file storage is required, verify that the file is owned by the intended user and has mode
0600. - Avoid placing the actual token directly in an interactive command that may be retained in shell history. Read it silently instead:
bash read -rsp "Notion API token: " NOTION_KEY printf '\n' install -m 600 /dev/null ~/.config/notion/api_key printf '%s\n' "$NOTION_KEY" > ~/.config/notion/api_key unset NOTION_KEY - Grant the Notion integration only the minimum capabilities and share only the resources required for its task.
- Revoke and rotate any token suspected of having been stored with permissive permissions or exposed through shell history.
