

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 2
click for more info
Not enough gems
Cost: 6 gems
1: What Is Context?
incomplete
2: Context As RAM
incomplete
3: New Sessions
incomplete
4: Token Economics
incomplete
5: Ignoring Files
incomplete
6: File Watcher
incomplete
7: Lost in the Middle
incomplete
8: Compaction
incomplete
9: Configure Compaction
incomplete
10: Undo and Redo
incomplete
11: Forking
incomplete
12: Secrets in Context
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Anything you put in an OpenCode session can become part of the model's context. That includes pasted text, file contents, and shell output. Copying or exporting the session can spread that information further.
So yes, developer secrets (passwords, API keys, tokens, etc.) can leak into "context" in many ways, not just through committed code.
Even if your provider doesn't use your data for training, putting secrets in context still sends them to that provider. Giving a remote model access to your plain-text secrets is a BIG risk and should absolutely be avoided.
Now, if you're running a model locally on your own hardware, the risk is much lower because at least the secret isn't leaving your machine. But even then, you should be careful about what secrets you put into context: you might accidentally reuse that session later with a different model. Also, your session history gets saved on disk, so if a session includes a plain-text secret, now there's another copy of it to worry about.
OpenCode's default permissions allow read for most files, but .env files ask for your approval by default.
The filesystem tools built into OpenCode also ask for approval before accessing paths outside the active project, but the shell tool is different: it runs with your user's host permissions, so treat shell access as real terminal access, not as a filesystem sandbox.
Not all secrets are in .env files. You can still leak secrets by:
Tune your permissions to deny reads of files you use for secrets, or require explicit approval. For example, this rule in opencode.jsonc blocks the read tool from opening .secrets files:
{
"$schema": "https://opencode.ai/config.json",
"permissions": [
{ "action": "read", "resource": "*.secrets", "effect": "deny" },
],
}
And just be careful. No single list can cover all the potential ways to leak secrets into context. If you notice a risk of leaking secrets in one of your projects, make a change to your workflow.
Outright block OpenCode's read tool from opening the project's (fake) .env secret.
Tell OpenCode to run and submit the CLI tests from the project root.