user.additionalFields config silently allows extraneous properties #2964

Open
opened 2026-03-13 10:30:55 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @nihalgonsalves on GitHub (Mar 2, 2026).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  • package.json

      "dependencies": {
        "better-auth": "^1.5.1"
      },
      "devDependencies": {
        "typescript": "^5.9.3"
      },
    
  • src/lib/auth.ts

    export const auth = betterAuth({
      user: {
        additionalFields: {
    			test: {
    				type: 'boolean',
    				'abc': 'def',
    			}
    		},
      },
    });
    
  • tsconfig.json

    {
      "compilerOptions": {
        "strict": true,
      }
    }
    

Current vs. Expected behavior

  • Current: Arbitrary properties are currently allowed, as long as you specify the required type. As a concrete example, I misspelled required as require, and there were no type errors. I only noticed later.
  • Expected: Additional properties should result in a type error.

What version of Better Auth are you using?

1.5.1

System info

{
  "system": {
    "platform": "darwin",
    "arch": "arm64",
    "version": "Darwin Kernel Version 25.3.0: Wed Jan 28 20:53:05 PST 2026; root:xnu-12377.81.4~5/RELEASE_ARM64_T6020",
    "release": "25.3.0",
    "cpuCount": 12,
    "cpuModel": "Apple M2 Max",
    "totalMemory": "32.00 GB",
    "freeMemory": "3.57 GB"
  },
  "node": {
    "version": "v24.14.0",
    "env": "development"
  },
  "packageManager": {
    "name": "npm",
    "version": "11.9.0"
  },
  "frameworks": null,
  "databases": null,
  "betterAuth": {
    "version": "^1.5.1",
    "config": {
      "user": {
        "additionalFields": {
          "test": {
            "type": "boolean",
            "abc": "def"
          }
        }
      }
    }
  }
}

Which area(s) are affected? (Select all that apply)

Types

Auth config (if applicable)


Additional context

No response

Originally created by @nihalgonsalves on GitHub (Mar 2, 2026). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce - `package.json` ```json "dependencies": { "better-auth": "^1.5.1" }, "devDependencies": { "typescript": "^5.9.3" }, ``` - `src/lib/auth.ts` ```tsx export const auth = betterAuth({ user: { additionalFields: { test: { type: 'boolean', 'abc': 'def', } }, }, }); ``` - `tsconfig.json` ```json { "compilerOptions": { "strict": true, } } ``` ### Current vs. Expected behavior - Current: Arbitrary properties are currently allowed, as long as you specify the required `type`. As a concrete example, I misspelled `required` as `require`, and there were no type errors. I only noticed later. - Expected: Additional properties should result in a type error. ### What version of Better Auth are you using? 1.5.1 ### System info ```bash { "system": { "platform": "darwin", "arch": "arm64", "version": "Darwin Kernel Version 25.3.0: Wed Jan 28 20:53:05 PST 2026; root:xnu-12377.81.4~5/RELEASE_ARM64_T6020", "release": "25.3.0", "cpuCount": 12, "cpuModel": "Apple M2 Max", "totalMemory": "32.00 GB", "freeMemory": "3.57 GB" }, "node": { "version": "v24.14.0", "env": "development" }, "packageManager": { "name": "npm", "version": "11.9.0" }, "frameworks": null, "databases": null, "betterAuth": { "version": "^1.5.1", "config": { "user": { "additionalFields": { "test": { "type": "boolean", "abc": "def" } } } } } } ``` ### Which area(s) are affected? (Select all that apply) Types ### Auth config (if applicable) ```typescript ``` ### Additional context _No response_
GiteaMirror added the bug label 2026-03-13 10:30:55 -05:00
Author
Owner

@GautamBytes commented on GitHub (Mar 3, 2026):

Looking into it!

@GautamBytes commented on GitHub (Mar 3, 2026): Looking into it!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#2964