Information
Servlets are secured by URL and each URL that is to be secured must be specified in the web.xml file describing the application.
A servlet can have multiple aliases and an application can have many servlets, making it easy to accidentally forget to secure an alias or URL for a servlet. If just one servlet URL is insecure, an intruder might be able to bypass security. Use wildcards to secure servlets wherever possible instead of specific URLs and configure the application to deny access to uncovered http methods.
Solution
Create aliases for each servlet. Assign a security constraint for each URL defined in alias. Add additional security by adding <deny-uncovered-http-methods /> to WEB-INF/web.xml to block all undeclared methods.
<servlet-mapping id="ServletMapping_1">
<servlet-name>MyServlet</servlet-name>
<url-pattern>/MyURLPattern</url-pattern>
</servlet-mapping>
<deny-uncovered-http-methods />
<!-- SECURITY CONSTRAINTS -->
<security-constraint id="SecurityConstraint_1">
<web-resource-collection id="WebResourceCollection_1">
<web-resource-name>Protected with Employee or Manager roles</web-resource-name>
<url-pattern>/MyURLPattern</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint id="AuthConstraint_1">
<role-name>Employee</role-name>
<role-name>Manager</role-name>
</auth-constraint>
</security-constraint>
Note: The security constraints can also be set in the code using annotations like @ServletSecurity
Impact:
Open Liberty secures URLs and not the underlying classes, if just one servlet URL is insecure, an intruder might be able to bypass security.