Title: [BUG] Password-protected deployment auth tokens can be forged · Issue #4759 · simstudioai/sim · GitHub
Open Graph Title: [BUG] Password-protected deployment auth tokens can be forged · Issue #4759 · simstudioai/sim
X Title: [BUG] Password-protected deployment auth tokens can be forged · Issue #4759 · simstudioai/sim
Description: Describe the bug Password-protected chat and form deployments use a base64-encoded authentication token that is not signed or bound to a server-side secret. The token format is: deploymentId:type:timestamp:truncatedPasswordHash The passw...
Open Graph Description: Describe the bug Password-protected chat and form deployments use a base64-encoded authentication token that is not signed or bound to a server-side secret. The token format is: deploymentId:type:t...
X Description: Describe the bug Password-protected chat and form deployments use a base64-encoded authentication token that is not signed or bound to a server-side secret. The token format is: deploymentId:type:t...
Opengraph URL: https://github.com/simstudioai/sim/issues/4759
X: @github
Domain: Github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[BUG] Password-protected deployment auth tokens can be forged","articleBody":"**Describe the bug**\n\nPassword-protected chat and form deployments use a base64-encoded authentication token that is not signed or bound to a server-side secret. The token format is:\n\n```text\ndeploymentId:type:timestamp:truncatedPasswordHash\n```\n\nThe password hash is `sha256(encryptedPassword).substring(0, 8)`, which gives only 32 bits of search space. `validateAuthToken()` accepts any token whose deployment ID matches, whose timestamp is within 24 hours, and whose 8-character password hash matches the current encrypted password value. Because the token is not authenticated with an HMAC/signature, a token can be created outside the server once the 32-bit hash value is guessed.\n\nAffected code:\n\n- `apps/sim/lib/core/security/deployment.ts`\n - `hashPassword()` truncates SHA-256 to 8 hex characters.\n - `encryptAuthToken()` returns plain base64 of the token fields.\n - `validateAuthToken()` validates field equality but does not verify a server-side signature.\n- `apps/sim/app/api/chat/utils.ts`\n - `validateChatAuth()` trusts `chat_auth_\u003cdeploymentId\u003e` when `validateAuthToken()` returns true.\n- `apps/sim/app/api/form/utils.ts`\n - `validateFormAuth()` trusts `form_auth_\u003cdeploymentId\u003e` when `validateAuthToken()` returns true.\n- `apps/sim/app/api/chat/[identifier]/route.ts` and `apps/sim/app/api/form/[identifier]/route.ts`\n - GET handlers return full deployment configuration when the forged cookie validates.\n\nThis was verified on commit `7b572f1f61a8bbcee31fd7389097814a71f8f094` and the same vulnerable implementation is still present in fetched `origin/main` at `e532e0a6da6fd22eee98310ba44e4fe50dec174a`.\n\n**To Reproduce**\n\nUse only a local/synthetic deployment ID and encrypted password value. Do not run this against production systems.\n\n1. Inspect `apps/sim/lib/core/security/deployment.ts`.\n2. Compute the same password hash used by the application:\n\n```js\nconst { createHash } = require('crypto')\nconst encryptedPassword = 'synthetic-encrypted-password-ciphertext'\nconst pwHash = createHash('sha256').update(encryptedPassword).digest('hex').substring(0, 8)\n```\n\n3. Construct a token outside the server:\n\n```js\nconst deploymentId = 'dep_safe_local_test'\nconst token = Buffer.from(`${deploymentId}:password:${Date.now()}:${pwHash}`).toString('base64')\n```\n\n4. Pass the token to the same validation logic:\n\n```js\nvalidateAuthToken(token, deploymentId, encryptedPassword) === true\n```\n\n5. A wrong hash is rejected and an expired timestamp is rejected, confirming that the acceptance condition is exactly the forgeable 8-character hash plus a fresh timestamp.\n\nLocal verification result:\n\n```text\nhash_bits=32\ncandidate_space=4294967296\nforged_fresh_valid=true\nwrong_hash_valid=false\nexpired_valid=false\n```\n\n**Expected behavior**\n\nDeployment authentication cookies should be unforgeable by clients. A token should only validate if it was issued by the server and protected with a server-side secret, such as an HMAC-signed payload, authenticated encrypted token, signed JWT with strict claims, or an opaque server-side session ID.\n\nThe password hash should not be used as a bearer capability. If a stateless token is required, validation should verify a cryptographic signature using constant-time comparison and should bind the token to the deployment ID, auth type, expiration, and any relevant session/version state.\n\n**Screenshots**\n\nNot applicable. The issue is in token construction and validation logic.\n\n**Additional context**\n\nSecurity impact:\n\n- Unauthorized access to password-protected chat/form deployments is possible if an attacker knows the deployment identifier and can find the 32-bit truncated password hash.\n- The public deployment identifier is exposed through deployment URLs.\n- A valid forged cookie can make protected GET routes return full deployment configuration and can allow POST flows to proceed as authenticated.\n- Since the timestamp is client-controlled and only checked for recency, an attacker who finds the hash can mint fresh tokens until the password/encrypted password value changes.\n\nRecommended remediation:\n\n- Replace plain base64 tokens with HMAC-signed tokens or opaque server-side session IDs.\n- Remove the truncated password hash from client-controlled token material.\n- Add rate limiting and monitoring for failed deployment-auth attempts.\n- Consider rotating deployment auth/session material after deploying a fix.\n\nDisclosure note:\n\nThe repository contains `.github/SECURITY.md`, which asks reporters to email `security@sim.ai` and not disclose vulnerabilities publicly. This file follows the repository's bug-report template for private maintainer handling rather than public issue publication.","author":{"url":"https://github.com/3em0","@type":"Person","name":"3em0"},"datePublished":"2026-05-27T12:32:31.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/4759/sim/issues/4759"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a6208c9a-bd15-a9dc-dfd3-446806e468d9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A308:2D915E:28D2D:37412:6A628455 |
| html-safe-nonce | 534376dcbbfc1904c9c0ebd152a2bfab438c149fea3f9f07f9e0ab5e333896bd |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMzA4OjJEOTE1RToyOEQyRDozNzQxMjo2QTYyODQ1NSIsInZpc2l0b3JfaWQiOiIyNjIyODc2ODU1MTc2NDMwNjc4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 826ca480443847bbbdba2d33c043553d2f8326aa43c44e3236cd68703af038cf |
| hovercard-subject-tag | issue:4532333574 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/simstudioai/sim/4759/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b8330eef860c3d57c2a69aada1f9c59e8b9a9ce33ff0ed96a2cd0a31b3110a49/simstudioai/sim/issues/4759 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b8330eef860c3d57c2a69aada1f9c59e8b9a9ce33ff0ed96a2cd0a31b3110a49/simstudioai/sim/issues/4759 |
| og:image:alt | Describe the bug Password-protected chat and form deployments use a base64-encoded authentication token that is not signed or bound to a server-side secret. The token format is: deploymentId:type:t... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | 3em0 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7a4ef49a11a2c05de16a801b29c54a151d2e3262d6fd17381ca13b5ae25dda8f |
| turbo-cache-control | no-preview |
| go-import | github.com/simstudioai/sim git https://github.com/simstudioai/sim.git |
| octolytics-dimension-user_id | 199344406 |
| octolytics-dimension-user_login | simstudioai |
| octolytics-dimension-repository_id | 912559512 |
| octolytics-dimension-repository_nwo | simstudioai/sim |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 912559512 |
| octolytics-dimension-repository_network_root_nwo | simstudioai/sim |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 97b18c8f1d2683a31995fd6e802daf9bf0d4d3f0 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width