1. Home
  2. Web App Vulnerabilities
  3. How to remediate – Apache Struts 2 DevMode Enabled

How to remediate – Apache Struts 2 DevMode Enabled

1. Introduction

Apache Struts 2 DevMode Enabled allows developers to operate the application in a development environment, which can expose sensitive information about the underlying system and installed components. This vulnerability affects web applications using Apache Struts 2 and could allow attackers to gather details about the Java version, Struts framework version, and other internal configurations. A successful exploit may lead to information disclosure, potentially aiding further attacks on the system.

2. Technical Explanation

Apache Struts 2 DevMode is a feature intended for debugging and development purposes. When enabled, it can leak details about the application stack during runtime. This includes information about classpaths, configuration files, and other internal components. An attacker could exploit this by sending crafted requests to the application server and analyzing the responses for sensitive data.

  • Root cause: The Apache Struts 2 framework is configured with development mode enabled in production environments.
  • Exploit mechanism: An attacker sends HTTP requests to the vulnerable application, examining the response headers or error messages for exposed information about the system’s configuration and installed components.
  • Scope: Affected systems are those running Apache Struts 2 with DevMode enabled.

3. Detection and Assessment

To confirm if a system is vulnerable, check the Struts configuration file or examine the application’s runtime environment for signs of development mode being active.

  • Quick checks: Examine the struts.xml file for the presence of the tag ``.
  • Scanning: Nessus plugin ID 16739 can detect Apache Struts 2 Dev Mode Enabled. Other vulnerability scanners may also have similar checks.
  • Logs and evidence: Look for verbose logging or debugging information in application logs that indicate development mode is active.
grep -r "struts.devMode" /opt/apache-struts

4. Solution / Remediation Steps

Disable Apache Struts 2 development mode to prevent information disclosure.

4.1 Preparation

  • Back up the struts.xml file before making any changes. Stop the application server if necessary, depending on your environment and configuration. A rollback plan involves restoring the original struts.xml file.
  • Ensure you have access to modify the Struts configuration files. Changes may require a service restart or redeployment.

4.2 Implementation

  1. Step 1: Open the struts.xml file in a text editor.
  2. Step 2: Locate the line containing ``.
  3. Step 3: Change the value from “true” to “false”. If the constant is not present, ensure it remains absent.
  4. Step 4: Save the changes to the struts.xml file.
  5. Step 5: Restart the application server for the changes to take effect.

4.3 Config or Code Example

Before

<constant name="struts.devMode" value="true"/>

After

<!-- constant name="struts.devMode" value="true"/>

4.4 Security Practices Relevant to This Vulnerability

Several security practices can help prevent this vulnerability type.

  • Least privilege: Restricting access to configuration files limits the potential impact of misconfigurations.
  • Secure defaults: Using secure default settings for application frameworks minimizes the risk of accidental exposure of sensitive information.
  • Configuration management: Regularly review and audit application configurations to identify and correct any security issues.

4.5 Automation (Optional)

Automation is not directly applicable in this case, as it requires modifying a configuration file. However, infrastructure-as-code tools can be used to enforce the desired configuration state.

# Example Ansible task to ensure struts.devMode is disabled
- name: Disable Struts Dev Mode
  lineinfile:
    path: /opt/apache-struts/struts.xml
    regexp: '^<constant name="struts.devMode" value="true"/>'
    state: absent
  notify: Restart application server

5. Verification / Validation

Confirm the fix by checking the Struts configuration file and verifying that development mode is disabled.

  • Post-fix check: Examine the struts.xml file; the tag `` should be absent or commented out.
  • Re-test: Re-run the quick check from Section 3 to confirm that development mode is no longer enabled.
  • Monitoring: Monitor application logs for verbose debugging information; absence of such logging indicates successful remediation.
grep -r "struts.devMode" /opt/apache-struts # Should return no results

6. Preventive Measures and Monitoring

Update security baselines to include a check for disabled development mode in Apache Struts 2 configurations. Implement regular configuration reviews as part of the change management process.

  • Baselines: Include a requirement to disable DevMode in your application security baseline or CIS control checklist.
  • Pipelines: Integrate static analysis tools into CI/CD pipelines to detect insecure configurations, such as enabled development mode.
  • Asset and patch process: Establish a regular schedule for reviewing and updating application configurations.

7. Risks, Side Effects, and Roll Back

  • Risk or side effect 1: Service interruption during restart. Mitigation: Schedule changes during off-peak hours and have a rollback plan ready.
  • Roll back: Restore the original struts.xml file and restart the application server.

8. References and Resources

Updated on October 26, 2025

Was this article helpful?

Related Articles