Vault Cortex implements a robust, two-layer security model designed to protect personal notes while enabling remote access. Unlike most MCP servers that operate without authentication, Vault Cortex treats read/write access to a vault as a sensitive capability, providing defense-in-depth through an AWS Lambda authorizer and a full OAuth 2.1 provider.
Security is enforced at two distinct boundaries in the reference deployment:
Authorization header before requests reach the server src/functions/authorizer.ts4-9The following diagram illustrates how a request from an MCP client is validated through both security layers.
Request Validation Sequence
Sources: src/functions/authorizer.ts47-83 src/vault-mcp/oauth/oauth-provider.ts150-160
The handler in src/functions/authorizer.ts serves as the first line of defense in AWS deployments. It is "path-aware," meaning it applies different logic based on the requested endpoint src/functions/authorizer.ts44-57
/.well-known/, /authorize, /token, /register, /revoke, and /healthz are permitted to bypass authorization to allow the OAuth discovery and handshake process to function src/functions/authorizer.ts34-42/mcp endpoint requires a valid bearer token. The authorizer accepts two types of credentials:
McpAuthToken secret exactly using safeEqual src/functions/authorizer.ts71-74verifyJwt src/functions/authorizer.ts76-79The authorizer relies on Resource.McpAuthToken.value provisioned via SST src/functions/authorizer.ts67
Sources: src/functions/authorizer.ts1-26 src/auth.ts1-15 sst.config.ts97
The OAuth implementation allows agents to request specific scopes (currently vault) and provides users with a consent interface.
| Entity | Role | Code Location |
|---|---|---|
createOAuthProvider | Factory that initializes the provider with SQLite persistence. | src/vault-mcp/oauth/oauth-provider.ts150-154 |
SqliteClientsStore | Persists dynamic client registrations to clients table in oauth.db. | src/vault-mcp/oauth/oauth-provider.ts99-103 |
mcpAuthRouter | SDK-managed routes for .well-known/mcp-configuration, /token, etc. | src/vault-mcp/oauth/oauth-routes.ts49-61 |
renderConsentPage | Generates the HTML form where users enter their MCP_AUTH_TOKEN to approve a client. | src/vault-mcp/oauth/consent-page.ts1-15 |
src/jwt.ts using only node:crypto to minimize the Lambda bundle size src/jwt.ts1-9REFRESH_TOKEN_TTL_S). Every use rotates the token and resets the window src/vault-mcp/oauth/oauth-provider.ts35-39consumeRefreshToken, it is deleted and a new one is issued to prevent replay src/vault-mcp/oauth/oauth-provider.ts195-210safeEqual (wrapping crypto.timingSafeEqual) to prevent timing attacks src/auth.ts17-25Sources: src/jwt.ts30-59 src/vault-mcp/oauth/oauth-provider.ts187-192 src/vault-mcp/oauth/oauth-provider.ts62-97
Beyond authentication, Vault Cortex implements extensive runtime protections to ensure data integrity and prevent common attack vectors SECURITY.md25-30
resolveSafePath() resolves then prefix-checks every path — ../../etc/passwd throws before filesystem access SECURITY.md32-35 toVaultRelativePath() normalizes backslashes and collapses ../ before checks SECURITY.md36-38sanitizeFtsQuery() strips FTS5 metacharacters and reserved words SECURITY.md57-60escapeVaultContentClosingTag() prevents vault content from breaking out of the <vault-content> data boundary in assembled prompts SECURITY.md61-64escapeHtml() is used on the OAuth consent page to escape client-supplied values SECURITY.md66-68atomicWriteFile) so readers never see partial content SECURITY.md71atomicWriteFileExclusive() uses link() on POSIX or O_EXCL on Windows to atomically create files without a check-then-write window SECURITY.md46-49safeHandler() catches exceptions and returns only the message, masking internal stack traces and container paths SECURITY.md86-92node), uses tini as PID 1, and strips package managers (npm/npx/yarn) from the runtime image SECURITY.md93-100Security Logic Entity Map
Sources: SECURITY.md25-106 src/jwt.ts50-75 src/functions/authorizer.ts47-83
Vault Cortex maintains a high security posture through a comprehensive toolchain integrated into the CI/CD pipeline SECURITY.md114-130:
:latest and :remote) for OS-layer and dependency CVEs SECURITY.md120-124Sources: SECURITY.md114-130 CONTRIBUTING.md121-130
Refresh this wiki
This wiki was recently refreshed. Please wait 6 days to refresh again.