Rule Definition
HTTP Session is active for long, will create multiple issue - 1) Security 2)Memory usage 3) Results into break of the authentication using session set to never expire or denial of service.
Remediation
Always set a definite timeout for sessions.
Violation Code Sample
Sample 1:
HttpSession sesssion = request.getSession(true);
sesssion.setMaxInactiveInterval(-1);
Sample 2:
<session-config>
<session-timeout>-1</session-timeout>
</session-config>
Sample 3:
HttpSession sesssion = request.getSession(true);
sesssion.setMaxInactiveInterval(0);
Fixed Code Sample
HttpSession sesssion = request.getSession(true);
sesssion.setMaxInactiveInterval(90);
Reference
https://www.owasp.org/index.php/Top_10-2017_A2-Broken_Authentication
https://cwe.mitre.org/data/definitions/613.html
Related Technologies
Technical Criterion
Secure Coding - Weak Security Features
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.