security(vscode): OAuth token stored in plaintext globalState
Summary
src/enterprise/auth/ssoProvider.ts stores the OAuth accessToken in context.globalState (lines 157, 187-188). VS Code globalState is persisted as unencrypted JSON on disk, making the token readable by any local process with file access.
Recommended Fix
Use context.secrets.store() / context.secrets.get() (VS Code SecretStorage API) for the token field. Store only non-sensitive fields (username, roles, provider ID) in globalState.
Severity
High — credential exposure at rest.
🤖 AI Agent: contributor-guide
Hello @user! 👋
Welcome to the microsoft/agent-governance-toolkit project! 🎉 We're thrilled to have you here, and thank you for taking the time to report this issue. Security is a top priority for us, and your detailed report is incredibly valuable. Let's dive into your concern!
🔍 Issue Analysis
Your observation about storing the OAuth accessToken in context.globalState is spot on. Storing sensitive credentials in plaintext can indeed lead to unintended exposure, especially if the file is accessible by other processes. Using the VS Code SecretStorage API (context.secrets.store() / context.secrets.get()) is a much safer alternative.
Based on your description, this issue likely pertains to the agent-compliance package, as it deals with compliance frameworks and audit logging, which often intersect with secure handling of sensitive data like OAuth tokens.
📂 Relevant Code
The file you mentioned, src/enterprise/auth/ssoProvider.ts, is likely located in the agent-compliance package. You can start by exploring the following directory:
agent-compliance/src/enterprise/auth/
Look for the ssoProvider.ts file and specifically review lines 157, 187-188 as you've highlighted. These lines should give you a clear view of how the accessToken is currently being stored.
📚 Helpful Resources
Here are some resources to help you get started with contributing to the project:
- CONTRIBUTING.md: Guidelines for contributing to the project, including how to set up your environment and submit a pull request.
- QUICKSTART.md: A quick guide to get the project up and running locally.
- Code of Conduct: Our expectations for respectful and inclusive collaboration.
🚀 Next Steps
Here’s how you can help resolve this issue:
- Investigate the Code: Review the
ssoProvider.tsfile in theagent-compliancepackage to confirm the issue and understand the current implementation. - Propose a Fix: Update the code to use the VS Code
SecretStorageAPI (context.secrets.store()/context.secrets.get()) for storing theaccessToken. Ensure that only non-sensitive fields (e.g., username, roles, provider ID) remain inglobalState. - Test Your Changes: Verify that the updated implementation works as expected and that the token is securely stored.
- Submit a Pull Request: Once you're satisfied with your changes, open a pull request. Be sure to include a clear description of the issue and how your fix addresses it.
If you need any help along the way, feel free to ask! We're here to support you. 😊
Thank you again for contributing to the project and helping us improve security. We’re excited to see your contributions! 🚀