Skip to content

Additional security/secret key 64 hex - #4

Open
amhost wants to merge 4 commits into
l3utterfly:mainfrom
amhost:fix/secret-key-64-hex
Open

amhost wants to merge 4 commits into
l3utterfly:mainfrom
amhost:fix/secret-key-64-hex

Conversation

@amhost

@amhost amhost commented Oct 18, 2026

Copy link
Copy Markdown

This pull request updates how server secret keys are generated and displayed, improving both security and usability. The main changes include replacing the password generator with a secure, 256-bit hex-encoded secret, updating the default secret key generation, and enhancing the UI to better display long secrets.

Security improvements:

  • Replaced the generatePassword function with a new generateSecretKey function that generates a 256-bit random authentication secret, hex-encoded for improved security. (src/services/user-settings-service.ts, src/services/user-settings-service.tsL1-R9)
  • Updated USER_SETTING_DEFAULTS to use the new generateSecretKey for SERVER_SECRET_KEY instead of the old password generator. (src/services/user-settings-service.ts, src/services/user-settings-service.tsL34-R40)

UI improvements:

  • Updated the CSS in LLMServerPanel.tsx to wrap long secrets at 16 characters per line and set a maximum width, making long hex secrets easier to read and copy. (src/screens/LLMServerPanel.tsx, src/screens/LLMServerPanel.tsxR1666-R1669)

…random

The default server secret was generated with Math.random(), which is not
a cryptographically secure source. Replace generatePassword() with
generateSecretKey(): 32 bytes from globalThis.crypto.getRandomValues,
hex-encoded to a 64-character (256-bit) secret.

Web Crypto is available in the renderer, so the esbuild
--platform=browser bundle builds without Node built-ins. Existing
installs keep their stored secret; only first-run defaults change.
A 64-character hex secret has no break points, so at 20px monospace it
rendered ~855px wide and overflowed the 360px modal on both sides.
Allow breaking anywhere and cap the width at 16 characters per line, so
a 64-char secret shows as four even rows at the existing font size. A
16-char legacy secret still renders on one line. Soft wraps do not
change the copied text.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant