Skip to content

Unsafe sed interpolation in check-token.sh can corrupt settings file #13

@digitalby

Description

@digitalby

hooks/check-token.sh lines 81-82 interpolate the refreshed token directly into a sed replacement expression using | as the delimiter:

sed -i '' "s|^${key}: .*|${key}: \"${val}\"|" "$file"

If ${val} (the new access token or refresh token) contains |, &, or \, sed will either error out or perform an incorrect substitution, potentially corrupting the user's .claude/spotify-ads-api.local.md settings file and breaking subsequent API calls. Spotify OAuth tokens are generally base64url-safe today, but this is unsafe input handling at a trust boundary and could break silently if the token format ever changes.

Additionally, line 91 uses ${modified_command//$access_token/$new_token} — the pattern side of bash's // expansion interprets glob metacharacters (*, ?, [), so a token containing those characters would not substitute correctly.

Suggested fix: escape sed metacharacters in ${val} before interpolation, or write the file using a safer method (e.g., printf + mv with a temp file, or yq/python for the YAML frontmatter).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions