Skip to content

stages/authenticator_validate: reject malformed WebAuthn assertions as an invalid device (cherry-pick #27479 to version-2026.8) - #28392

Open
authentik-cherry-pick[bot] wants to merge 1 commit into
version-2026.8from
cherry-pick/27479-to-version-2026.8
Open

authentik-cherry-pick[bot] wants to merge 1 commit into
version-2026.8from
cherry-pick/27479-to-version-2026.8

Conversation

@authentik-cherry-pick

Copy link
Copy Markdown
Contributor

Cherry-pick of #27479 to version-2026.8 branch.

Original PR: #27479
Original Author: @ryanpesek
Cherry-picked commit: 3931139

…s an invalid device (#27479)

validate_challenge_webauthn() only caught InvalidJSONStructure from
parse_authentication_credential_json(). py_webauthn raises
InvalidAuthenticationResponse when a credential field isn't valid base64url,
and a bare ValueError (binascii.Error) when userHandle isn't, so such an
assertion, for example a forged passwordless login, failed the flow with the
error screen and a system_exception event instead of a validation error.

Catch WebAuthnException and ValueError around the parse, as the WebAuthn
setup stage does around verify_registration_response(). This covers both
callers: the authenticator validation stage and the identification stage's
passkey login.
@netlify

netlify Bot commented Dec 1, 2026

Copy link
Copy Markdown

✅ Deploy Preview for authentik-integrations ready!

Name Link
🔨 Latest commit a7d3a95
🔍 Latest deploy log https://app.netlify.com/projects/authentik-integrations/deploys/6b0f58c17bb3aa2891c83ee3
😎 Deploy Preview https://deploy-preview-28392--authentik-integrations.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Dec 1, 2026

Copy link
Copy Markdown

✅ Deploy Preview for authentik-storybook ready!

Name Link
🔨 Latest commit a7d3a95
🔍 Latest deploy log https://app.netlify.com/projects/authentik-storybook/deploys/6b0f58c168e3e827ee0f74cf
😎 Deploy Preview https://deploy-preview-28392--authentik-storybook.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov

codecov Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
4475 1 4474 1
View the top 1 failed test(s) by shortest run time
authentik.stages.authenticator_validate.tests.test_webauthn.AuthenticatorValidateStageWebAuthnTests::test_validate_challenge_malformed_userless
Stack Traces | 0.489s run time
self = <unittest.case._Outcome object at 0x70af279dd4e0>
test_case = <authentik.stages.authenticator_validate.tests.test_webauthn.AuthenticatorValidateStageWebAuthnTests testMethod=test_validate_challenge_malformed_userless>
subTest = False

    @contextlib.contextmanager
    def testPartExecutor(self, test_case, subTest=False):
        old_success = self.success
        self.success = True
        try:
>           yield

.../hostedtoolcache/Python/3.14.10........./x64/lib/python3.14/unittest/case.py:58: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <authentik.stages.authenticator_validate.tests.test_webauthn.AuthenticatorValidateStageWebAuthnTests testMethod=test_validate_challenge_malformed_userless>
result = <TestCaseFunction test_validate_challenge_malformed_userless>

    def run(self, result=None):
        if result is None:
            result = self.defaultTestResult()
            startTestRun = getattr(result, 'startTestRun', None)
            stopTestRun = getattr(result, 'stopTestRun', None)
            if startTestRun is not None:
                startTestRun()
        else:
            stopTestRun = None
    
        result.startTest(self)
        try:
            testMethod = getattr(self, self._testMethodName)
            if (getattr(self.__class__, "__unittest_skip__", False) or
                getattr(testMethod, "__unittest_skip__", False)):
                # If the class or method was skipped.
                skip_why = (getattr(self.__class__, '__unittest_skip_why__', '')
                            or getattr(testMethod, '__unittest_skip_why__', ''))
                _addSkip(result, self, skip_why)
                return result
    
            expecting_failure = (
                getattr(self, "__unittest_expecting_failure__", False) or
                getattr(testMethod, "__unittest_expecting_failure__", False)
            )
            outcome = _Outcome(result)
            start_time = time.perf_counter()
            try:
                self._outcome = outcome
    
                with outcome.testPartExecutor(self):
                    self._callSetUp()
                if outcome.success:
                    outcome.expecting_failure = expecting_failure
                    with outcome.testPartExecutor(self):
>                       self._callTestMethod(testMethod)

.../hostedtoolcache/Python/3.14.10........./x64/lib/python3.14/unittest/case.py:669: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <authentik.stages.authenticator_validate.tests.test_webauthn.AuthenticatorValidateStageWebAuthnTests testMethod=test_validate_challenge_malformed_userless>
method = <bound method AuthenticatorValidateStageWebAuthnTests.test_validate_challenge_malformed_userless of <authentik.stages....ate.tests.test_webauthn.AuthenticatorValidateStageWebAuthnTests testMethod=test_validate_challenge_malformed_userless>>

    def _callTestMethod(self, method):
>       result = method()
                 ^^^^^^^^

.../hostedtoolcache/Python/3.14.10........./x64/lib/python3.14/unittest/case.py:615: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <authentik.stages.authenticator_validate.tests.test_webauthn.AuthenticatorValidateStageWebAuthnTests testMethod=test_validate_challenge_malformed_userless>

    def test_validate_challenge_malformed_userless(self):
        """Test that a malformed assertion in a passwordless flow gets a validation error"""
>       flow = create_test_flow(FlowDesignation.AUTHENTICATION)
                                ^^^^^^^^^^^^^^^
E       NameError: name 'FlowDesignation' is not defined

.../authenticator_validate/tests/test_webauthn.py:571: NameError

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant