Let an agent sign in for you without showing the model your password
You are halfway through a task with an agent. It has found the settings page and filled in most of the form, and then it stops: "To continue, please paste your password here." Or it needs an API key for the service it is about to call, and the chat box is right there. It feels harmless because the conversation feels private. But a chat is not a safe. Why the chat box is the wrong place Anything…
When working with an agent, it's crucial to ensure that sensitive information, such as passwords or API keys, never enters the chat or is stored within the model's context. The model's context includes any text it reads or writes during a conversation, so placing a password or key in the chat could potentially expose it to the model.
Instead, utilize a separate storage solution, often referred to as a credential store or vault, that is not accessible to the model. This store should fetch the necessary secret when the agent needs to perform a specific action, such as signing into a service or calling an API with a token. The model should not directly access the stored secret; it should only receive references or results from the store.
Additionally, it's important to limit the scope of the tokens used by the agent to the specific task at hand. This means creating a unique token for each job, ensuring it only has the necessary permissions (e.g., read-only access) and expiring it after use. Instead of relying on a master password or a single broad key, use OAuth or app-specific passwords, which can be revoked without affecting other passwords used elsewhere.
Two-factor authentication (2FA) should also be handled by the user, not the agent. Keep logs of all secret uses, including the secret, timestamp, and the task it was used for, and review these logs regularly to detect any unauthorized access. If a secret is accidentally exposed, immediately rotate it at the source, revoke the old version, and clean up any copies found.
Remember, the safer habit is to avoid pasting passwords or keys into the chat altogether, and instead use scoped tokens, up-to-date 2FA, and manual confirmation for high-risk actions like payments, account deletions, or security settings.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.