Video in progress

Junior 🌱 Spring

How do you expose Actuator endpoints over HTTP, and which ones should you never leave open?

You list the endpoints you need in management.endpoints.web.exposure.include; by default only health is exposed over HTTP. env, heapdump and configprops reveal sensitive things, so don't open them to the internet.

📖 Answer

management:
  endpoints:
    web:
      exposure:
        include: health,info,metrics,prometheus
  endpoint:
    health:
      show-details: when-authorized
  server:
    port: 9091        # actuator on a separate port

Dangerous endpoints:

  • /actuator/env and /configprops: settings; Boot tries to mask values, but not all of them;
  • /actuator/heapdump: a memory copy that may contain passwords, tokens and user data;
  • /actuator/loggers: you can change the log level with a POST;
  • /actuator/shutdown: shuts the application down (off by default).

In prod, don't leave include: "*" open to everyone. There have been cases in real companies where data leaked through heapdump.

Usually actuator sits on a separate port and is reachable only from the internal network, or you write a separate rule in Spring Security for EndpointRequest.toAnyEndpoint(). You expose only what monitoring needs.