Skip to content

fix: prevent raw API key exposure in agent commands - #12

Merged
SecurityQQ merged 1 commit into
mainfrom
fix/api-key-hygiene
Mar 26, 2026
Merged

fix: prevent raw API key exposure in agent commands#12
SecurityQQ merged 1 commit into
mainfrom
fix/api-key-hygiene

Conversation

@SecurityQQ

Copy link
Copy Markdown
Contributor

Summary

  • Prevents raw API key values from leaking into agent conversation context and terminal history
  • All auth/setup commands now use $VARG_API_KEY env var references instead of raw key placeholders

Changes

Critical Rule #8 added: "API key hygiene" — never write a raw API key value into a bash command. Always export VARG_API_KEY=... first and reference $VARG_API_KEY in all subsequent commands.

Option A (user has existing key): Instead of asking the user to paste the key to the agent, instruct them to run export VARG_API_KEY=<their_key> in their terminal themselves.

Option B (OTP signup): Capture the verify-otp response into a $VARG_AUTH shell variable and immediately export VARG_API_KEY from it — the raw key value never appears as a standalone string in a command.

Save credentials: Uses $VARG_API_KEY variable interpolation instead of THE_KEY placeholder (which agents would substitute with the actual key).

Stripe checkout: Extracts access_token into $VARG_ACCESS_TOKEN from the captured $VARG_AUTH response instead of using a bare ACCESS_TOKEN placeholder.

Version bumped to 2.0.4.

Problem

Previously, the skill instructed agents to use patterns like:

echo '{"api_key":"THE_KEY",...}' > ~/.varg/credentials
curl -H "Authorization: Bearer THE_KEY" ...

Agents interpret THE_KEY as a placeholder and substitute the raw API key, which then appears in bash commands and conversation history.

After

export VARG_API_KEY=$(echo "$VARG_AUTH" | grep -o '"api_key":"[^"]*"' | cut -d'"' -f4)
curl -H "Authorization: Bearer $VARG_API_KEY" ...

The key is stored in an env var immediately and only referenced by variable name.

- Add 'API key hygiene' as Critical Rule #8: never write raw key values
  into bash commands, always use $VARG_API_KEY env var reference
- Option A (existing key): instruct user to run export themselves
  instead of pasting key to the agent
- Option B (OTP): capture verify-otp response into $VARG_AUTH variable,
  immediately export VARG_API_KEY from it via grep/cut
- Save credentials: use $VARG_API_KEY variable reference instead of
  THE_KEY placeholder that agents substitute with the raw value
- Stripe checkout: extract access_token into $VARG_ACCESS_TOKEN from
  the captured $VARG_AUTH response
- Bump version to 2.0.4
@coderabbitai

coderabbitai Bot commented Mar 26, 2026

Copy link
Copy Markdown
📝 Walkthrough

walkthrough

documentation updates to varg-ai/skill.md covering version 2.0.4, including refined api key onboarding flows for both option a (export-based) and option b (otp verification), improved credential saving with timestamps, updated authorization headers using environment variables, and new api key hygiene guidance emphasizing security best practices.

changes

cohort / file(s) summary
auth flow & credential updates
varg-ai/SKILL.md
bumped version to 2.0.4; restructured option a onboarding to use export VARG_API_KEY instead of pasting keys; improved option b otp flow with variable capture (VARG_AUTH, VARG_API_KEY); updated credential saving to include created_at and reference shell variables; adjusted authorization headers to use Bearer $VARG_API_KEY; added explicit api key hygiene rules discouraging raw key exposure in commands; updated .env guidance and stripe checkout token extraction.

estimated code review effort

🎯 2 (simple) | ⏱️ ~12 minutes

possibly related prs

poem

🔐 keys locked up safe and sound,
no pasting in the chat around,
variables dance where secrets play,
hygiene rules light up the way! ✨

human meow 🐾

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed the title clearly and specifically summarizes the main change: preventing raw api key exposure in agent commands, which matches the core objective of the entire changeset.
Description check ✅ Passed the description is directly related to the changeset, explaining the problem, solution, and specific changes made throughout the skill.md file to address api key hygiene.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/api-key-hygiene

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
varg-ai/SKILL.md (1)

94-97: inconsistent placeholder handling - USER_EMAIL should also be a variable

line 97 correctly uses $VARG_API_KEY for the api key but still has USER_EMAIL as a raw placeholder. for consistency with the api key hygiene approach, this should probably be $USER_EMAIL (captured from user input or extracted from $VARG_AUTH)

suggested approach for consistency
-mkdir -p ~/.varg && echo "{\"api_key\":\"$VARG_API_KEY\",\"email\":\"USER_EMAIL\",\"created_at\":\"$(date -u +%Y-%m-%dT%H:%M:%SZ)\"}" > ~/.varg/credentials && chmod 600 ~/.varg/credentials
+mkdir -p ~/.varg && echo "{\"api_key\":\"$VARG_API_KEY\",\"email\":\"$USER_EMAIL\",\"created_at\":\"$(date -u +%Y-%m-%dT%H:%M:%SZ)\"}" > ~/.varg/credentials && chmod 600 ~/.varg/credentials

could extract email from VARG_AUTH at line 87:

export USER_EMAIL=$(echo "$VARG_AUTH" | grep -o '"email":"[^"]*"' | cut -d'"' -f4)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@varg-ai/SKILL.md` around lines 94 - 97, Replace the raw placeholder
USER_EMAIL in the credentials write command with the variable $USER_EMAIL and
ensure $USER_EMAIL is set earlier by extracting the email from the VARG_AUTH
payload (e.g., parse VARG_AUTH for the "email" field and export USER_EMAIL) so
the mkdir/echo command uses the variable ($VARG_API_KEY and $USER_EMAIL) rather
than a literal placeholder.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@varg-ai/SKILL.md`:
- Line 165: SKILL.md rule `#8` mandates exporting VARG_API_KEY and never printing
raw keys, but setup.ts and setup.sh currently extract and display literal API
keys and prompt users to paste them; update both setup.ts and setup.sh to (1)
stop echoing or printing the raw key, (2) automatically export the key into the
environment as VARG_API_KEY (or instruct the script to write an export command
to the user’s shell profile without showing the value), and (3) update any
prompts to accept/use $VARG_API_KEY (or an instruction to run export) instead of
asking users to paste raw values; ensure references to VARG_API_KEY are used
consistently and remove any code paths that call out or log the raw key.
- Around line 63-69: The placeholder notation is inconsistent: setup.ts and
setup.sh use "varg_xxx" while SKILL.md uses "<their_key>"; pick one style and
make all three consistent (prefer using varg_xxx to indicate format), update
SKILL.md's example line "export VARG_API_KEY=<their_key>" to "export
VARG_API_KEY=varg_xxx" (or alternatively update setup.ts/setup.sh to use
<their_key> if you prefer that style) so the placeholder symbol is identical
across setup.ts, setup.sh and SKILL.md and the docs instruct users to replace
that placeholder with their real key.

---

Nitpick comments:
In `@varg-ai/SKILL.md`:
- Around line 94-97: Replace the raw placeholder USER_EMAIL in the credentials
write command with the variable $USER_EMAIL and ensure $USER_EMAIL is set
earlier by extracting the email from the VARG_AUTH payload (e.g., parse
VARG_AUTH for the "email" field and export USER_EMAIL) so the mkdir/echo command
uses the variable ($VARG_API_KEY and $USER_EMAIL) rather than a literal
placeholder.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5bb1c4ed-3e98-487c-be1f-d5c638759850

📥 Commits

Reviewing files that changed from the base of the PR and between 13daaa3 and c59f6b4.

📒 Files selected for processing (1)
  • varg-ai/SKILL.md

Comment thread varg-ai/SKILL.md
Comment on lines +63 to +69
Ask the user if they have a `VARG_API_KEY`. If yes, tell them to export it in their terminal:

```bash
export VARG_API_KEY=<their_key>
```

**Important:** Do NOT ask the user to paste the raw key to you. Ask them to run the `export` command themselves. Then skip to "Save credentials" below.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# check setup.ts and setup.sh for varg_xxx placeholder usage

echo "=== setup.ts api key instructions ==="
rg -n -A5 -B5 'export VARG_API_KEY=varg' varg-ai/scripts/setup.ts

echo "=== setup.sh api key instructions ==="
rg -n -A5 -B5 'export VARG_API_KEY=varg' varg-ai/scripts/setup.sh

Repository: vargHQ/skills

Length of output: 1168


placeholder notation inconsistency between docs

setup.ts and setup.sh use varg_xxx as the api key placeholder, but SKILL.md uses <their_key>. match the placeholder style across all three files for consistency. keeping varg_xxx suggests a varg-format key, while <their_key> is clearer about what users should do (replace with actual key).

the actual guidance is sound - all three correctly show that users should replace the placeholder with their real key, not paste literal values. this is just about making the notation consistent. meow 🐱

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@varg-ai/SKILL.md` around lines 63 - 69, The placeholder notation is
inconsistent: setup.ts and setup.sh use "varg_xxx" while SKILL.md uses
"<their_key>"; pick one style and make all three consistent (prefer using
varg_xxx to indicate format), update SKILL.md's example line "export
VARG_API_KEY=<their_key>" to "export VARG_API_KEY=varg_xxx" (or alternatively
update setup.ts/setup.sh to use <their_key> if you prefer that style) so the
placeholder symbol is identical across setup.ts, setup.sh and SKILL.md and the
docs instruct users to replace that placeholder with their real key.

Comment thread varg-ai/SKILL.md
5. **Duration constraints differ by model** -- kling-v3: 3-15s (integer only). kling-v2.5: ONLY 5 or 10. Check [models.md](references/models.md).
6. **Gateway namespace** -- use `providerOptions: { varg: {...} }`, never `fal`, when going through the gateway (both modes).
7. **Renders cost money** -- 1 credit = 1 cent. A typical 3-clip video costs $2-5. Use preview mode (local) or cheap models to iterate.
8. **API key hygiene** -- Never write a raw API key value into a bash command. After obtaining a key (from the user or OTP response), immediately `export VARG_API_KEY=...` and use `$VARG_API_KEY` in all subsequent commands. This prevents keys from leaking into conversation context and terminal history.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

critical rule #8 is well-written but implementation is incomplete

the rule clearly states the hygiene requirements and rationale, which is great

however, as flagged in earlier comments, the setup scripts (setup.ts and setup.sh) don't currently follow this rule - they extract and display raw api keys and instruct users to paste literal key values

this rule should be enforced consistently across all files in the repo

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@varg-ai/SKILL.md` at line 165, SKILL.md rule `#8` mandates exporting
VARG_API_KEY and never printing raw keys, but setup.ts and setup.sh currently
extract and display literal API keys and prompt users to paste them; update both
setup.ts and setup.sh to (1) stop echoing or printing the raw key, (2)
automatically export the key into the environment as VARG_API_KEY (or instruct
the script to write an export command to the user’s shell profile without
showing the value), and (3) update any prompts to accept/use $VARG_API_KEY (or
an instruction to run export) instead of asking users to paste raw values;
ensure references to VARG_API_KEY are used consistently and remove any code
paths that call out or log the raw key.

@SecurityQQ
SecurityQQ merged commit a576323 into main Mar 26, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant