|
| 1 | +# Security Hardening |
| 2 | + |
| 3 | +sda-spring-boot-commons changes some default configuration for security reasons. |
| 4 | +This document provides a brief overview about the addressed risks. |
| 5 | + |
| 6 | +## Risk: Accessing critical resources from untrusted environments |
| 7 | + |
| 8 | +To avoid exposing internal resources, Spring Boot Actuator is configured to listen on a separate |
| 9 | +port. |
| 10 | +Health, metrics and other sensitive information can't be exposed to the internet by accident, e.g. |
| 11 | +by missing to exclude the actuator path. |
| 12 | + |
| 13 | +Custom critical resources can be exposed at the management port by implementing |
| 14 | +`org.springframework.boot.actuate.endpoint.web.annotation.RestControllerEndpoint` or |
| 15 | +`org.springframework.boot.actuate.endpoint.web.annotation.ControllerEndpoint`. |
| 16 | +Note that there is an [open discussion](https://github.com/spring-projects/spring-boot/issues/31768) |
| 17 | +about these annotations. |
| 18 | +As long as they are not deprecated, it is suggested to use them because the use is most similar to |
| 19 | +controllers used in regular REST APIs. |
| 20 | + |
| 21 | +## Risk: Root start |
| 22 | + |
| 23 | +If the service is started with extended privileges as the root user, an attacker can more easily |
| 24 | +attack the operating system after taking over from the container. |
| 25 | + |
| 26 | +The default configuration is capable to run as no root, listening to ports 8080 and 8081. |
| 27 | +Deployment checks must ensure, that the container is not configured with a root user. |
| 28 | + |
| 29 | +## Risk: Exploitation of HTTP methods |
| 30 | + |
| 31 | +The HTTP method `TRACE` is disabled by default to mitigate [Cross Site Tracing](https://owasp.org/www-community/attacks/Cross_Site_Tracing). |
| 32 | + |
| 33 | +## Risk: Loss of source IP address |
| 34 | + |
| 35 | +We expect, the services built with sda-spring-boot-commons are deployed behind a proxy, e.g. an |
| 36 | +Ingress in Kubernetes. |
| 37 | + |
| 38 | +This library is configured by default to consider `X-Forwarded-*` headers to identify the original |
| 39 | +caller. |
| 40 | + |
| 41 | +## Risk: Detection of confidential components |
| 42 | + |
| 43 | +Knowing the components used in a software makes it easier to look for and exploit specific CVEs. |
| 44 | + |
| 45 | +Custom error handlers and other configurations are used to avoid identifiable default output from |
| 46 | +the framework and its components. |
| 47 | + |
| 48 | +## Risk: Lack of visibility |
| 49 | + |
| 50 | +If there is no visibility, there is no response to an abusive action and attackers can explore risks |
| 51 | +undisturbed. |
| 52 | + |
| 53 | +Logs are written to standard out by default to comply with Kubernetes environments. |
| 54 | +Prometheus metrics are exposed as expected by SDA environments. |
| 55 | + |
| 56 | +## Risk: Buffer Overflow |
| 57 | + |
| 58 | +The size of request and response headers is limited to 8KiB. |
| 59 | + |
| 60 | +## Header |
| 61 | + |
| 62 | +By configuring the default headers, the following risks are addressed: |
| 63 | + |
| 64 | +- Cross-Site Scripting |
| 65 | +- Content interpretation by the browser |
| 66 | +- Content loading in Flash and PDFs |
| 67 | +- Clickjacking |
| 68 | +- Sharing visited URLs with third parties |
| 69 | +- Abuse from Cross-Origin Resource Sharing |
0 commit comments