Advertisement
Intermediate ASP.NET Core, Health Checks

Why should the detailed /health endpoint (with full dependency status breakdown) generally not be exposed publicly on the internet, and how do you restrict access to it?

Short answer

A detailed health check response can leak sensitive infrastructure information (which database provider is used, internal service names, version numbers, error messages potentially revealing internal architecture) to anyone who can reach the endpoint -- best practice restricts…

Save ASP.NET Core mock interview
Advertisement
AModel answer
A detailed health check response can leak sensitive infrastructure information (which database provider is used, internal service names, version numbers, error messages potentially revealing internal architecture) to anyone who can reach the endpoint -- best practice restricts detailed health endpoints to internal networks only (via network-level restrictions, a reverse proxy rule, or [Authorize] combined with a policy requiring an internal-only claim), while optionally exposing a minimal, information-free public endpoint (just 200 OK / 503) for basic external uptime monitoring.
// Program.cs -- separate detailed (internal) and minimal (public) health endpoints
app.MapHealthChecks("/health/detailed", new HealthCheckOptions {
    ResponseWriter = WriteDetailedJson
}).RequireAuthorization("InternalOnly");

app.MapHealthChecks("/health", new HealthCheckOptions {
    ResponseWriter = (context, report) => context.Response.WriteAsync(report.Status.ToString())
});  // minimal, publicly safe
Real-world example
A security review flags that an API's detailed /health endpoint was publicly exposing its exact SQL Server version, Redis hostname, and internal service names, leading the team to restrict the detailed endpoint to internal network access only while keeping a minimal public endpoint for basic uptime monitoring.
Likely follow-ups
  • What network-level (versus application-level) approaches exist for restricting access to the detailed endpoint?
  • What specific pieces of information are most risky to leak via a health check response?
Related topics