T09 · Insecure Skill Coding Practices
- Location
scripts/notion.py:17- Finding
Hard-Coded Notion Integration Token
- Content
View full analysis
Vulnerability Details
File Location:
scripts/notion.py:17
Vulnerability Type: Hard-coded credential / plaintext secret
Risk Level: HighVulnerable Code
python NOTION_TOKEN = os.environ.get("NOTION_TOKEN", "ntn_R368210231801s4MMnfbcy6pFjMrW0hk2DhcmK01vmJ9n8")The exposed credential is subsequently included in every API request:
python def _headers(): return { "Authorization": f"Bearer {NOTION_TOKEN}", "Notion-Version": NOTION_VERSION, "Content-Type": "application/json", }The insecure fallback behavior is also explicitly documented in
SKILL.md:15-20:markdown Set your Notion integration token: ```bash export NOTION_TOKEN=ntn_...Or the default token embedded in the script will be used.
text ### Technical Analysis The script embeds a live-format Notion integration token as the default value of `NOTION_TOKEN`. If the environment variable is absent, the program silently authenticates with this shared credential. Any person with access to the package, source repository, build artifacts, logs, or historical revisions can extract the token and use it independently of the CLI. Notion integration tokens authorize access to resources shared with the corresponding integration. The script supports searching and reading accessible content as well as creating pages and appending blocks. Consequently, the exposed token could permit both disclosure and modification of workspace information, depending on the integration's configured capabilities and page/database access. Embedding the credential also creates a cross-user boundary problem: users who do not configure their own token may unknowingly query or modify resources belonging to the token owner. ### Attack Path 1. An attacker obtains the skill package, source code, or a repository revision containing `scripts/notion.py`. 2. The attacker reads line 17 and extracts the embedded Notion integration token. 3. The attacker sends requests to ...[truncated 1188 chars]- Remediation
View remediation
Remediation Suggestions
- Revoke the exposed Notion integration token immediately and issue a replacement. Treat it as compromised even if no misuse has been observed.
- Remove the hard-coded fallback and require an externally supplied credential:
python NOTION_TOKEN = os.environ.get("NOTION_TOKEN") if not NOTION_TOKEN: raise RuntimeError("NOTION_TOKEN must be configured") - Supply the token through an approved secret manager, protected environment injection mechanism, or operating-system credential store.
- Remove statements in
SKILL.mdthat instruct users to rely on an embedded default token. Document secure configuration and token rotation instead. - Purge the exposed value from repository history, release archives, package registries, cached build artifacts, logs, and documentation.
- Review the integration's Notion audit history for unauthorized activity and inspect accessible pages and databases for unexpected modifications.
- Apply least privilege to the replacement integration: grant only necessary capabilities and share only the pages or databases required for its intended operation.
- Add automated secret scanning to source-control and release pipelines, and block commits containing Notion token patterns or other credentials.
- Avoid printing credentials or request authorization headers in diagnostics and ensure environment variables are not exposed in logs.
