Skip to content

[fix][core] stop returning credentials from the current user endpoint (24.05) - #7940

Open
ar2rsawseen wants to merge 1 commit into
release.24.05from
backport/current-user-no-credentials-2405
Open

[fix][core] stop returning credentials from the current user endpoint (24.05)#7940
ar2rsawseen wants to merge 1 commit into
release.24.05from
backport/current-user-no-credentials-2405

Conversation

@ar2rsawseen

Copy link
Copy Markdown
Member

Backport of #7939 to release.24.05.

What

/o/users/me returned the caller's member document with only the password removed:

usersApi.getCurrentUser = function(params) {
    delete params.member.password;
    common.returnOutput(params, params.member);

So the response carried the account's api_key, and for members using two factor auth the stored secret for that factor as well. The neighbouring reads already treat both as sensitive: getUserById and getAllUsers project api_key away, and the member event payloads delete it with a comment saying it must never be forwarded. This was the one read path that handed it out.

Separately, a token that was restricted to specific applications could reach this endpoint. The restriction in verify_token is only compared when the request itself names an application, and this request never does, so the restriction was not applied.

Change

  1. Answer with a copy of the member that has password, api_key and two_factor_auth removed. A copy, so nothing later in the request sees a mutated member.
  2. Refuse a token restricted to specific applications on this endpoint. It reports the caller's own account and belongs to no application, so an application restricted token has no business reading it.

Tokens with no application restriction behave exactly as before.

Why this is safe to change

  • Nothing in the product reads the key from here. The dashboard takes api_key from the server rendered globals, and there is a dedicated /api-key route for a member who wants their own key. No frontend code calls /o/users/me at all.
  • No test expects the key. The existing assertions on this endpoint check email, full_name, global_admin and username.
  • The existing token suites still pass by construction. The token used against /o/users/me in test/2.api/14.authorize.token.js is created with no app, so it is unrestricted and unaffected. The token in App-scoped token enforces its app restriction is pinned to ^/o/actions, so it never reaches this endpoint either.
  • two_factor_auth.enabled remains available where the UI actually reads it, from the user listing.

Verification

Two cases added:

  • test/2.api/02.read.user.js: the response still carries the account's own fields but has no api_key, no password and no two_factor_auth.
  • test/2.api/14.authorize.token.js: a token restricted to one application, with no endpoint restriction, is refused on /o/users/me. This is a different token shape from the existing app restriction case, which is endpoint pinned.

Lint and node --check clean on all changed files.

/o/users/me answered with the caller's member document after deleting only the password,
so the response carried the account's api_key and, for members using two factor auth, the
stored secret for that factor. The neighbouring reads already treat both as sensitive:
getUserById and getAllUsers project api_key away, and the member event payloads delete it
with a comment saying it must never be forwarded. This was the one read path that returned
it.

Answer with a copy of the member that has the password, the api_key and the two factor
object removed. Nothing in the product reads the key from here: the dashboard takes it from
the server rendered globals, and a member who wants their own key has the /api-key route.

Also refuse a token that was restricted to specific applications on this endpoint. It
reports the caller's own account and belongs to no application, so a token deliberately
limited to some applications has no business reading it. The restriction in verify_token is
only compared when the request itself names an application, and this request never does, so
without this an app restricted token still reached account level data.

Tokens with no application restriction keep working exactly as before, which is what the
dashboard and the existing suites use.
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