Too long strings in user_metadata causing authentication to break
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- go
- Domain
- authentication
Research direction
The payload names no implementation files; start at the auth.admin.updateUserById flow and the SSR cookie handling described in the report. Reproduce with short and long user_metadata values, compare the resulting access_token cookies, and check discussion #9972 for related behavior; done should mean the failure is understood and malformed cookies or a silent authentication break are addressed.
Written by the indexing model from the issue text.
Description
Bug report
- I confirm this is a bug with Supabase, not with my own application.
- I confirm I have searched the Docs, GitHub Discussions, and Discord.
Describe the bug
We've encountered an unexpected behavior when updating user_metadata using the supabase.auth.admin.updateUserById method. It appears that there's an undocumented length limitation on the values stored in user_metadata. When this limit is exceeded, it causes authentication to break in an unclear manner and results in multiple, malformed cookies being set.
It's not per key-value pair, it's the accumulated length of the meta_data. A bunch of short key-value pairs results in the same behavior.
We are using the SSR package with the name in the cookieOptions set to access_token.
// This works fine
await supabase.auth.admin.updateUserById("user-id-here", {
user_metadata: {
images: "short string",
},
})
// This breaks authentication
await supabase.auth.admin.updateUserById("user-id-here", {
user_metadata: {
images: "long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string long string",
},
})
When the value exceeds a certain undocumented length, the following issues occur:
- The update appears to succeed but actually breaks the user's authentication.
- Multiple cookies are set with incorrect names (e.g., "access_token.0", "access_token.1").
- The content of these cookies is malformed:
- The first cookie starts with "base64-" as expected, but is truncated.
- The second cookie does not start with "base64-" and appears to be a fragment of a base64 encoded string.
- These issues manifest as problems with the access token, causing the user to be unable to log in or use the application again.
To Reproduce
- Use the supabase.auth.admin.updateUserById method to update a user's metadata.
- Set a value in the user_metadata object with a shorter string.
- Observe that the update succeeds.
- Now, try to update the same field with a longer string. I haven't found the exact length.
- Observe that this causes the authentication to break without a clear error message.
- Check the cookies set by the application and observe multiple, incorrectly named and malformed cookies.
Expected behavior
A clear and concise description of what you expected to happen.
Additional context
This issue seems to be related to the discussion in #9972, where similar unexpected behavior with user_metadata was reported. However, our case specifically highlights a potential length limitation and cookie malformation that wasn't mentioned in that discussion.
- Dominant language
- Go
- Stars
- 2.6k
- Forks
- 764
- Avg merge
- 5d 3h
- Merged PRs (30d)
- 39
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from supabase/auth
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 1/5 Under an hour Newbie friendliness 86/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Similar issues
-
optimization optimization:agents-md-curator
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
githubnext/gh-aw-cao#13143 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
blinklabs-io/bursa#904 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
yanet-platform/ipfw-go#129 ·
-
bug confmap/provider/googlesecretmanagerprovider needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
open-telemetry/opentelemetry-collector-contrib#51273 · 2 comments ·
-
bug: AI Gateway client filter lists "Unknown" twice when NULL and literal Unknown clients coexist Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 90/100