Skip to content

bug: remove hardcoded API token and session secret from app.js - #220

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1787161126-remove-hardcoded-token
Open

bug: remove hardcoded API token and session secret from app.js#220
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1787161126-remove-hardcoded-token

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Aug 19, 2026

Copy link
Copy Markdown

Summary

app.js declared an API token as a string literal and printed it to stdout on every start, and configured express-session with the literal 'keyboard cat'. Both are hardcoded credentials (CWE-798); the logged token also leaks into any log aggregation.

  • Deleted the token entirely — it was dead code (no other reference in the repo), so there is nothing to re-plumb:
    -var token = 'SECRET_TOKEN_[REDACTED]';
    -console.log('token: ' + token);
  • Session config now comes from the environment via two new helpers in utils.js:
    session({ secret: utils.session_secret(), name: 'connect.sid', cookie: utils.session_cookie() })
    session_secret(env = process.env) returns SESSION_SECRET when it is >= 32 chars; in production it throws (fail closed) rather than falling back, otherwise it warns and uses an ephemeral crypto.randomBytes(32) value. session_cookie(env) keeps path: '/' and adds httpOnly: true, sameSite: 'lax', and secure (on in production, overridable with SESSION_COOKIE_SECURE).
  • tests/session-config.test.js (tap) asserts app.js contains no token/secret literal and no console.log of a token, plus the helper behaviors. 6/6 pass locally.
  • README documents the new env vars and notes the leaked token value must be rotated wherever it was issued.

Devin-Org: engineering


Devin Review

Status Commit
⚪ Not started

Run Devin Review

Open in Devin Review (Staging)

Comment thread app.js
var dustHelpers = require('dustjs-helpers');
var cons = require('consolidate');
const hbs = require('hbs')
var utils = require('./utils');
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