Skip to content

🐞 Bug Report: Scrypt password verification fails in production after upgrading to NuxtHub 0.10.* on Cloudflare #478

@mrkaashee

Description

@mrkaashee

Password verification with scrypt fails in production after upgrading to NuxtHub 0.10.* (self-hosted on Cloudflare). Verification returns false in production while working correctly in local development. This worked fine before the upgrade.

Timeline:

  • ✅ Before NuxtHub 0.10.*: Password verification working on Cloudflare
  • ❌ After NuxtHub 0.10.*: Password verification fails on Cloudflare
  • ✅ Local development: Still works with same code

Demo Test Results:

Local Development (Working):

{
  "env": {
    "runtimePassword": true,
    "envPassword": true,
    "runtimePasswordLength": 64,
    "envPasswordLength": 64,
    "runtimePasswordFirst10": "b20cdc51db...",
    "envPasswordFirst10": "b20cdc51db...",
    "passwordsMatch": true
  },
  "test": {
    "password": "test_password_123",
    "hashed": "$scrypt$n=4096,r=8,p=1$+k9xuB+I5F721jgsXwgDWg$/9PmZvto+/9VMH5f1hkRS8ro6dTcgQYGtVUk7ivJokfD9AGMYfXqF+Gl0pX3M88h3J+r9otjmsXBVkHqqMGJ0A",
    "verifySuccess": true,
    "verifyError": null
  }
}

Production Cloudflare (Failing):

{
  "env": {
    "runtimePassword": true,
    "envPassword": true,
    "runtimePasswordLength": 64,
    "envPasswordLength": 64,
    "runtimePasswordFirst10": "b20cdc51db...",
    "envPasswordFirst10": "b20cdc51db...",
    "passwordsMatch": true
  },
  "test": {
    "password": "test_password_123",
    "hashed": "$scrypt$n=4096,r=8,p=1$5WeNlLN/bmDBQXmpY/DB+A$EtxwxX0G8fQjAOPggUY3pr2IGG+JgF3wU8GDKPuVxNE1le+zAgof5i6LYGHXlAT/3c0SmziuPS2AjgKUwgogtQ",
    "verifySuccess": false,
    "verifyError": null
  }
}

Key Observations:

  1. Hashing succeeds in both environments
  2. Verification fails silently (verifySuccess: false) in production only
  3. No errors thrown - makes debugging difficult

Test Code Used:

// Update your test endpoint to check more details
export default eventHandler(async event => {
  const config = useRuntimeConfig(event)

  // Check both runtime config and environment variables
  const runtimePassword = config.session?.password
  const envPassword = process.env.NUXT_SESSION_PASSWORD

  const results = {
    env: {
      runtimePassword: !!runtimePassword,
      envPassword: !!envPassword,
      runtimePasswordLength: runtimePassword?.length || 0,
      envPasswordLength: envPassword?.length || 0,
      runtimePasswordFirst10: runtimePassword?.substring(0, 10) + '...',
      envPasswordFirst10: envPassword?.substring(0, 10) + '...',
      passwordsMatch: runtimePassword === envPassword
    },
    test: {
      password: 'test_password_123',
      hashed: null,
      verifySuccess: null,
      verifyError: null
    }
  }

  try {
    // Log the actual hash operation
    results.test.hashed = await hashPassword(results.test.password)
    console.log('Generated hash:', results.test.hashed)

    // Try verification
    results.test.verifySuccess = await verifyPassword(results.test.hashed, results.test.password)
  }
  catch (e: any) {
    results.test.verifyError = e.message
    console.error('Verify error:', e)
  }

  return results
})

Environment

Operating system Windows 10.0.26200
CPU 13th Gen Intel(R) Core(TM) i7-13700H (20 cores)
Node.js version v24.11.1
nuxt/cli version 3.31.1
Package manager [email protected]
Nuxt version 4.2.2
Nitro version 2.12.9
Builder [email protected]
Config auth, compatibilityDate, css, devtools, eslint, experimental, future, hub, modules, ui
Modules @nuxt/[email protected], @nuxt/[email protected], @nuxthub/[email protected], @nuxt/[email protected], [email protected], @nuxt/[email protected]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions