Skip to content

Missing input length validation on username field causes outsized log generation in /login-actions/authenticate #50903

Closed

Description

@Dweep018

Before reporting an issue

  • I have read and understood the above terms for submitting issues, and I understand that my issue may be closed without action if I do not follow them.

Area

authentication

Describe the bug

The username field in Keycloak's login form accepts excessively long input and reflects the full value verbatim in authentication logs without any length restriction or truncation.

During testing, submitting ~124,000 characters in the username field caused the log file to grow from 34KB to 161KB in a single unauthenticated request - an amplification of over 127x compared to a normal login attempt.

The full username is written to the WARN log entry under type="LOGIN_ERROR" without any truncation, meaning any unauthenticated user
can generate disproportionate log data on the server with a single request.

Version

26.5.3

Regression

  • The issue is a regression

Expected behavior

The username field should enforce a reasonable maximum length limit before the value is passed to the logging layer. Any input exceeding that
limit should be truncated or rejected, preventing disproportionate log growth from a single request.

Actual behavior

The full username value is written verbatim to the authentication logs regardless of length. A single unauthenticated request with ~124,000
characters in the username field caused the log file to grow from 34KB to 161KB — over 127x the size of a normal login attempt.

How to Reproduce?

  1. Start a standard Keycloak instance
  2. Navigate to the login page: http://localhost:8080/realms/master/protocol/openid-connect/auth?client_id=security-admin-console&response_type=code & enter any wrong credentials and submit the login form to be redirected.
  3. You will be redirected to: /realms/master/login-actions/authenticate with parameters: execution, client_id, tab_id, client_data
  4. Now in the username field, paste a very long string (~124,000 characters) & submit the form
  5. Observe the logs and the log file size.

Anything else?

The username value is reflected in logs via org.keycloak.events under the LOGIN_ERROR event type.
Measured evidence:

  • Log file before: 34KB
  • Log file after 1 request: 161KB
  • Input length: ~124,000 characters
  • Authentication required: None
  • All realms affected: Yes

POC:
Image

Activity

  1. added
    kind/bug
    on Jul 15, 2026
  2. added theissue type on Jul 15, 2026
  3. added
    area/authentication
    on Jul 15, 2026
  4. self-assigned this
    on Jul 20, 2026
  5. 17 remaining items

  6. sguilhen commented on Aug 31, 2026

    @sguilhen
    Contributor

    @msdaly200 @rmartinc This was reported as a regression in #52154 - I tested and indeed only 26.7.x is affected (26.6.x works well). I am adding a backport label here so the fix makes its way to 26.7.

  7. sguilhen commented on Aug 31, 2026

    @sguilhen
    Contributor

    Sent #52253 - only had to adjust the location of the organization tests as in 26.7 the org tests were still in the legacy testsuite.

  8. added a commit that references this issue on Sep 16, 2026
    e24fd0f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Fields

No fields configured for bug.

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions