Secure code review

Reviewing authentication enforcement and abuse resistance

Secure implementation: code, settings, gate arranged to illustrate reviewing authentication enforcement and abuse resistance.

Authentication assurance includes the entire identity lifecycle, not only the primary login prompt. Understanding authentication enforcement and abuse resistance helps establish which security property the feature needs and where that property is actually enforced.

What does this involve?

Authentication establishes who is making a request and the strength and freshness of that evidence. Enrolment, recovery, alternate channels and changes to authenticators are part of the same boundary. An impressive login screen provides little assurance if another path grants equivalent access with weaker checks.

This section contains general requirements for the security of authentication mechanisms as well as setting out the different expectations for levels. L2 applications must force the use of multi-factor authentication (MFA). L3 applications must use hardware-based authentication, performed in an attested and trusted execution environment (TEE). This could include device-bound passkeys, eIDAS Level of Assurance (LoA) High enforced authenticators, authenticators with NIST Authenticator Assurance Level 3 (AAL3) assurance, or an equivalent mechanism.

While this is a relatively aggressive stance on MFA, it is critical to raise the bar around this to protect users, and any attempt to relax these requirements should be accompanied by a clear plan on how the risks around authentication will be mitigated, taking into account NIST's guidance and research on the topic.

Why it matters

Consider a realistic failure: a strong sign-in journey is bypassed through a weaker enrolment, recovery or alternative authentication path.

Account access can lead to disclosure, unwanted changes or misuse of a trusted identity. The consequence depends on the account's permissions and the actions available after authentication, rather than the appearance of the login mechanism.

A code audit connects a stated requirement to the implementation responsible for enforcing it. Source review and targeted behavioural checks should explain the same boundary and any relevant exceptions.

How penetration testers check for it

Review the specific control expectations below against the code, deployment and observable application behaviour.

  • Confirm that controls to prevent attacks such as credential stuffing and password brute force are implemented according to the application's security documentation.
  • Confirm that default user accounts are not present in the application or are disabled.
  • Confirm that either a multi-factor authentication mechanism or a combination of single-factor authentication mechanisms, must be used in order to access the application. For L3, one of the factors must be a hardware-based authentication mechanism which provides compromise and impersonation resistance against phishing attacks while verifying the intent to authenticate by requiring a user-initiated action. Relaxing any of the considerations in this requirement requires a fully documented rationale and a comprehensive set of mitigating controls.
  • Verify that, if the application includes multiple authentication pathways, there are no undocumented pathways and that security controls and authentication strength are enforced consistently.
  • Confirm that users are notified of suspicious authentication attempts (successful or unsuccessful). This may include authentication attempts from an unusual location or client, partially successful authentication (only one of multiple factors), an authentication attempt after a long period of inactivity or a successful authentication after several unsuccessful attempts.
  • Confirm that email is not used as either a single-factor or multi-factor authentication mechanism.
  • Confirm that users are notified after updates to authentication details, such as credential resets or modification of the username or email address.
  • Confirm that valid users cannot be deduced from failed authentication challenges, such as by basing on error messages, HTTP response codes, or different response times. Registration and forgot password functionality must also have this protection.
  • Check expiry, reuse and the binding of challenges to their intended action.
  • Follow successful authentication into the operation that trusts it.

How to fix it

Implement the required boundary in the component that actually performs the sensitive operation and retain focused regression coverage.

  • Apply consistent verification at trusted boundaries.
  • Protect enrolment, replacement and recovery as carefully as login.
  • Require appropriate fresh evidence for sensitive changes.
  • Record important authentication events without retaining secrets.

Authentication and authorisation answer different questions. Establishing identity does not grant unrestricted permission to records or privileged functions.

Recheck the changed behaviour against the original failure conditions and the legitimate user journey. Keep enough evidence to show which release and configuration were verified, and include related entry points that depend on the same security decision.

Read about our methodology or contact pentested.com to discuss the security of your application code.

See your first test report this week.

Book a 30 minute demo. We will verify one of your targets with you and run a test against it, so you can judge the results on your own systems.

Book a demo