T09 · Insecure Skill Coding Practices
- Location
scripts/auth-google.sh:140- Finding
OAuth Access and Refresh Tokens Are Persisted in a Predictable Plaintext File
- Content
View full analysis
"$TOKEN_FILE" chmod 600 "$TOKEN_FILE" print_success "Tokens saved to: $TOKEN_FILE" # Log to audit (redact tokens) log_action "EXCHANGE_CODE" "success" # Export for current session export ACCESS_TOKEN="$access_token" export REFRESH_TOKEN="$refresh_token" ``` ```bash # Read refresh token from file local refresh_token=$(grep -oP '"refresh_token":\s*"\K[^"]*' "$TOKEN_FILE" | head -1) if [ -z "$refresh_token" ]; then print_error "Refresh token not found" return 1 fi # Make POST request to refresh local response=$(curl -s -X POST \ "https://oauth2.googleapis.com/token" \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "client_id=$GOOGLE_CLIENT_ID" \ -d "client_secret=$GOOGLE_CLIENT_SECRET" \ -d "refresh_token=$refresh_token" \ -d "grant_type=refresh_token") if echo "$response" | grep -q '"access_token"'; then local access_token=$(echo "$response" | grep -oP '"access_token":\s*"\K[^"]*' | head -1) local new_refresh_token=$(echo "$response" | grep -oP '"refresh_token":\s*"\K[^"]*' | head -1) local expires_in=$(echo "$response" | grep -oP '"expires_in":\s* ...[truncated 2590 chars]- Remediation
View remediation
