Skip to main content
LowAPIOWASP A01:2021CWE-540

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

  1. 1Expose only the entity sets the API actually needs, rather than registering the whole EDM model.
  2. 2Restrict $expand, $select and $filter with query-option limits so navigation properties cannot be used to reach unrelated entities.
  3. 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

C#
services.AddControllers().AddOData(opt => opt
    .AddRouteComponents("odata", GetEdmModel())
    .Select()
    .Filter()
    .OrderBy()
    .SetMaxTop(100));   // no unbounded $expand, capped page size

Require auth on the metadata route

C#
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.

See every api check

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.

Propose a checkHow a check is built

Scan your own site for odata $metadata document publicly served

VulnRadar runs this check and hundreds more against a URL in seconds. No agent to install, just paste a URL.

Or scan this site as a demoRead the docs

OData $metadata document publicly served fix | VulnRadar