fix: prevent raw API key exposure in agent commands - #12
Conversation
- 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
📝 Walkthroughwalkthroughdocumentation 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
estimated code review effort🎯 2 (simple) | ⏱️ ~12 minutes possibly related prs
poem
human meow 🐾 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
varg-ai/SKILL.md (1)
94-97: inconsistent placeholder handling - USER_EMAIL should also be a variableline 97 correctly uses
$VARG_API_KEYfor the api key but still hasUSER_EMAILas 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/credentialscould 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
| 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. |
There was a problem hiding this comment.
🧩 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.shRepository: 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.
| 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. |
There was a problem hiding this comment.
🛠️ 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.
Summary
$VARG_API_KEYenv var references instead of raw key placeholdersChanges
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_KEYin 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-otpresponse into a$VARG_AUTHshell variable and immediatelyexport VARG_API_KEYfrom it — the raw key value never appears as a standalone string in a command.Save credentials: Uses
$VARG_API_KEYvariable interpolation instead ofTHE_KEYplaceholder (which agents would substitute with the actual key).Stripe checkout: Extracts
access_tokeninto$VARG_ACCESS_TOKENfrom the captured$VARG_AUTHresponse instead of using a bareACCESS_TOKENplaceholder.Version bumped to 2.0.4.
Problem
Previously, the skill instructed agents to use patterns like:
Agents interpret
THE_KEYas a placeholder and substitute the raw API key, which then appears in bash commands and conversation history.After
The key is stored in an env var immediately and only referenced by variable name.