Execution After Redirect (EAR)

Incomplete Base
Structure: Simple
Description

Execution After Redirect (EAR) occurs when a web application sends a redirect response to a user's browser but continues to run server-side code, potentially performing unintended actions.

Extended Description

This vulnerability happens because the server-side logic doesn't properly halt execution after issuing a redirect command (like an HTTP 302 or 303 status). Instead of stopping, the application proceeds to execute the remaining code in the script or function. This leftover code can perform dangerous operations like updating databases, processing payments, or changing user sessions, even though the user is already being sent to a new page. From a security perspective, EAR is dangerous because an attacker can often interrupt or ignore the redirect. By using tools or crafting requests, they can let the redirect happen in the browser while still receiving and acting upon the results of the unauthorized server-side execution. To prevent this, developers must ensure the application flow terminates immediately after sending a redirect, typically by using explicit return or exit statements in the code.

Common Consequences 1
Scope: OtherConfidentialityIntegrityAvailability

Impact: Alter Execution LogicExecute Unauthorized Code or Commands

This weakness could affect the control flow of the application and allow execution of untrusted code.

Detection Methods 1
Black Box
This issue might not be detected if testing is performed using a web browser, because the browser might obey the redirect and move the user to a different page before the application has produced outputs that indicate something is amiss.
Demonstrative Examples 1

ID : DX-180

This code queries a server and displays its status when a request comes from an authorized IP address.

Code Example:

Bad
PHP
php

...*

This code redirects unauthorized users, but continues to execute code after calling http_redirect(). This means even unauthorized users may be able to access the contents of the page or perform a DoS attack on the server being queried. Also, note that this code is vulnerable to an IP address spoofing attack (Improper Removal of Sensitive Information Before Storage or Transfer).
Observed Examples 7
CVE-2013-1402Execution-after-redirect allows access to application configuration details.
CVE-2009-1936chain: library file sends a redirect if it is directly requested but continues to execute, allowing remote file inclusion and path traversal.
CVE-2007-2713Remote attackers can obtain access to administrator functionality through EAR.
CVE-2007-4932Remote attackers can obtain access to administrator functionality through EAR.
CVE-2007-5578Bypass of authentication step through EAR.
CVE-2007-2713Chain: Execution after redirect triggers eval injection.
CVE-2007-6652chain: execution after redirect allows non-administrator to perform static code injection.
References 1
Fear the EAR: Discovering and Mitigating Execution After Redirect Vulnerabilities
Adam Doupé, Bryce Boe, Christopher Kruegel, and Giovanni Vigna
ID: REF-565
Modes of Introduction
Implementation
Alternate Terms

Redirect Without Exit