4.4.12 Ensure security constraints are specified to protect web applications

Information

Protect web applications by configuring security constraints for all web resources using either deployment descriptor and/or annotations.

Specifying security constraints allows fine grained access control to protected resources. This can be done either using deployment descriptor and/or annotations.

Solution

Set <security-constraint> elements in the web.xml deployment descriptor file of each application or use annotations in the code.Example using security-constraint:

<security-constraint>
<web-resource-collection>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>testing</role-name>
</auth-constraint>
</security-constraint>

Example using annotations:

@WebServlet("/myServlet")
@ServletSecurity(
httpMethodConstraints = {
@HttpMethodConstraint(value = "GET", rolesAllowed = "user"),
@HttpMethodConstraint(value = "POST", rolesAllowed = "manager",
transportGuarantee = TransportGuarantee.CONFIDENTIAL),
}
)
public class myServlet extends HttpServlet {
// servlet code...
}

See Also

https://workbench.cisecurity.org/benchmarks/7724

Item Details

Category: ACCESS CONTROL

References: 800-53|AC-6

Plugin: Unix

Control ID: 19b884fbd815203eb43a9a8a378b04ac009fcb05821f7e54c7eabfa025d35acc