How to fix: OData $metadata document publicly served
An OData $metadata document, describing the service's entity model, is served from this URL. OData services such as SAP Gateway, Microsoft Dynamics and ASP.NET Core OData publish one automatically.
Why it matters
The metadata document is a complete schema dump: every entity set, every property with its exact name and type, every navigation property linking one entity to another, and every callable function and action. Combined with OData's query syntax, which lets a caller select, filter and expand across those navigation properties, it is enough to reach data the intended UI never displays.
Publishing $metadata is part of how OData works, so this is informational rather than a defect on its own. It matters because it turns any authorization gap into an immediately exploitable one: the caller does not have to guess a property name or an entity relationship, they can read it. The real control is server-side, restricting which entity sets are exposed and which query options are permitted.
How to fix it
- 1Expose only the entity sets the API actually needs, rather than registering the whole EDM model.
- 2Restrict $expand, $select and $filter with query-option limits so navigation properties cannot be used to reach unrelated entities.
- 3Require authentication on the metadata endpoint itself if the model is not meant to be public.
Code examples
ASP.NET Core OData: bound query options
services.AddControllers().AddOData(opt => opt
.AddRouteComponents("odata", GetEdmModel())
.Select()
.Filter()
.OrderBy()
.SetMaxTop(100)); // no unbounded $expand, capped page sizeRequire auth on the metadata route
app.MapWhen(
ctx => ctx.Request.Path.StartsWithSegments("/odata/$metadata"),
branch => branch.UseAuthentication().UseAuthorization());References
Detected automatically by VulnRadar. The check id is api-odata-metadata-document-exposed, stable across every scan so you can filter or diff on it.
More api checks
- LowTRACE method referenced in API response body
- InfoREST endpoint allows DELETE
- LowGraphQL introspection field suggestions
- MediumGraphQL endpoint has no rate-limit headers
- LowOpenAPI server URL leaks internal host
- LowCORS preflight result not cached
- HighBearer token in URL query string
- MediumJSONP callback parameter accepted
Questions
- How severe is OData $metadata document publicly served?
- VulnRadar rates this low severity in the api category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
- Does VulnRadar check for this automatically?
- Yes. It runs as part of every scan under the check id api-odata-metadata-document-exposed, which stays the same between runs so you can filter, diff, or gate CI on it.
- Which standards does OData $metadata document publicly served map to?
- It maps to CWE-540. In the OWASP Top 10 it falls under A01:2021.
Missing a check?
The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.