Mitigation Strategy: Explicit Network Binding
-
Description:
- Locate Gretty Configuration: Open the
build.gradle
(orbuild.gradle.kts
) file. - Find the
gretty
Block: Locate thegretty { ... }
configuration block. - Set
httpAddress
: Within thegretty
block, add or modify thehttpAddress
property. Set it to'127.0.0.1'
(localhost) or a trusted internal IP. Do not use'0.0.0.0'
.gretty { httpAddress = '127.0.0.1' // other configurations... }
- Restart Gretty: Restart the Gretty server.
- Verify: Use
netstat
to confirm the listening address.
- Locate Gretty Configuration: Open the
-
Threats Mitigated:
- Accidental Exposure of Development Environment: (Severity: High) - Prevents external access.
- Unintentional exposure of .gradle or build artifacts: (Severity: Medium) - Reduces the attack surface.
-
Impact:
- Accidental Exposure of Development Environment: Risk significantly reduced (local access only).
- Unintentional exposure of .gradle or build artifacts: Risk moderately reduced (harder to access).
-
Currently Implemented:
- Yes/No/Partially: (Specify one)
- Location:
build.gradle
,gretty
block.
-
Missing Implementation:
- If "No" or "Partially", specify where it's missing or incorrect (e.g., "Set to
0.0.0.0
", "Not configured").
- If "No" or "Partially", specify where it's missing or incorrect (e.g., "Set to
Mitigation Strategy: Strict Configuration Separation
-
Description:
- Create Separate Configuration Files: Create distinct files (e.g.,
jetty-web-dev.xml
,jetty-web-prod.xml
). - Use
configFile
in Gretty: Inbuild.gradle
, use theconfigFile
property within the appropriate Gretty task (e.g.,appRun
,farmRun
) to specify the correct file for each environment.appRun { configFile = file('src/main/webapp/WEB-INF/jetty-web-dev.xml') } farmRun { // Or a different task for production configFile = file('src/main/webapp/WEB-INF/jetty-web-prod.xml') }
- Avoid Default Configurations: Do not rely on Gretty's default loading. Always specify the file explicitly.
- Review Configuration Files: Ensure each file contains only appropriate settings for its environment.
- Create Separate Configuration Files: Create distinct files (e.g.,
-
Threats Mitigated:
- Inadvertent Deployment of Development Configurations: (Severity: High) - Prevents dev settings in production.
-
Impact:
- Inadvertent Deployment of Development Configurations: Risk significantly reduced (correct file loaded).
-
Currently Implemented:
- Yes/No/Partially: (Specify one)
- Location:
build.gradle
, Gretty task configurations, and separate configuration files.
-
Missing Implementation:
- If "No" or "Partially", describe what's missing (e.g., "Same file for all environments", "Not using
configFile
").
- If "No" or "Partially", describe what's missing (e.g., "Same file for all environments", "Not using
Mitigation Strategy: Explicit Servlet Container Version
-
Description:
- Locate Gretty Configuration: Open
build.gradle
. - Find the
gretty
Block: Locategretty { ... }
. - Set
servletContainer
: Add or modify theservletContainer
property. Set it to a specific, recent version (e.g.,'jetty9.4'
,'tomcat9'
). Do not rely on the default.gretty { servletContainer = 'jetty9.4' // Be specific and up-to-date! // other configurations... }
- Check for Compatibility: Ensure the version is compatible.
- Update Regularly: Reconsider the version during dependency updates.
- Locate Gretty Configuration: Open
-
Threats Mitigated:
- Dependency Vulnerabilities (Indirect): (Severity: Variable) - Prevents using a vulnerable default.
-
Impact:
- Dependency Vulnerabilities (Indirect): Risk reduced (controlled container version).
-
Currently Implemented:
- Yes/No/Partially: (Specify one)
- Location:
build.gradle
,gretty
block.
-
Missing Implementation:
- If "No" or "Partially", describe what's missing (e.g., "Not specifying
servletContainer
", "Outdated version").
- If "No" or "Partially", describe what's missing (e.g., "Not specifying
Mitigation Strategy: Enable and Configure Java Security Manager (via Gretty/JVM Arguments)
-
Description:
- Determine if Required: Assess if your application needs the Security Manager.
- Create a Security Policy File: Create a file (e.g.,
security.policy
) defining permissions. - Enable in Gretty/JVM: Add JVM arguments in
build.gradle
within thejvmArgs
property of a Gretty task:appRun { jvmArgs = [ '-Djava.security.manager', '-Djava.security.policy=src/main/resources/security.policy' ] }
- Test Extensively: Test with the Security Manager enabled.
- Iterative Refinement: Start restrictive, add permissions as needed.
-
Threats Mitigated:
- Overriding Security Managers: (Severity: High) - Enforces access control.
- Various Code-Level Vulnerabilities: (Severity: Variable) - Restricts code actions.
-
Impact:
- Overriding Security Managers: Risk eliminated (if configured correctly).
- Various Code-Level Vulnerabilities: Risk significantly reduced.
-
Currently Implemented:
- Yes/No/Partially: (Specify one)
- Location:
build.gradle
(JVM arguments), and a security policy file.
-
Missing Implementation:
- If "No" or "Partially", describe what's missing (e.g., "Not enabled", "Policy file missing", "Overly permissive policy").
Mitigation Strategy: Careful Web Root Configuration (using webappDir
)
-
Description:
- Identify Web Root: Determine the directory Gretty serves.
- Review Contents: Ensure it only contains files to be served.
- Remove Sensitive Files: Remove
.gradle
,build
, source code, etc. - Configure
webappDir
(If Necessary): Customize the web root:gretty { webappDir = file('src/main/my-custom-webapp') // other configurations... }
- Verify: Try to access files that should not be accessible.
-
Threats Mitigated:
- Unintentional exposure of .gradle or build artifacts: (Severity: Medium) - Prevents serving sensitive files.
-
Impact:
- Unintentional exposure of .gradle or build artifacts: Risk significantly reduced.
-
Currently Implemented:
- Yes/No/Partially: (Specify one)
- Location:
build.gradle
(webappDir
property), and web root contents.
-
Missing Implementation:
- If "No" or "Partially", describe what's missing (e.g., "
.gradle
in web root", "Sensitive files present").
- If "No" or "Partially", describe what's missing (e.g., "