Base · Medium

CWE-698: Execution After Redirect (EAR)

The web application sends a redirect to another location, but instead of exiting, it executes additional code.

CWE-698 · Base Level ·7 CVEs

Description

The web application sends a redirect to another location, but instead of exiting, it executes additional code.

Potential Impact

Other, Confidentiality, Integrity, Availability

Alter Execution Logic, Execute Unauthorized Code or Commands

Demonstrative Examples

This code queries a server and displays its status when a request comes from an authorized IP address.
Bad
$requestingIP = $_SERVER['REMOTE_ADDR'];if(!in_array($requestingIP,$ipAllowList)){echo "You are not authorized to view this page";http_redirect($errorPageURL);}$status = getServerStatus();echo $status;
                     ...
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 (CWE-212).

Detection Methods

  • 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.

Real-World CVE Examples

CVE IDDescription
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.

Frequently Asked Questions

What is CWE-698?

CWE-698 (Execution After Redirect (EAR)) is a software weakness identified by MITRE's Common Weakness Enumeration. It is classified as a Base-level weakness. The web application sends a redirect to another location, but instead of exiting, it executes additional code.

How can CWE-698 be exploited?

Attackers can exploit CWE-698 (Execution After Redirect (EAR)) to alter execution logic, execute unauthorized code or commands. This weakness is typically introduced during the Implementation phase of software development.

How do I prevent CWE-698?

Follow secure coding practices, conduct code reviews, and use automated security testing tools (SAST/DAST) to detect this weakness early in the development lifecycle.

What is the severity of CWE-698?

CWE-698 is classified as a Base-level weakness (Medium abstraction). It has been observed in 7 real-world CVEs.