← Back to projects

PYTHON / WEB & API SECURITY

OpenAPI Auth Drift

See which access condition a small security edit changes.

Resolve inheritance and operation overrides in two local OpenAPI files, then report anonymous access, scope reductions and AND–OR changes separately.

  • Python
  • OpenAPI 3.0 / 3.1
  • JSON / YAML
Synthetic example walkthrough

Three changes, three different meanings

Compare the conditions before and after in three examples.

GET /invoices

Anonymous path in the model

An empty list replaces the global rule

Before

Global bearerAuthDocument level
/invoicesInherits the global rule

Authentication required

After

/invoicesOperation override
security: []Inherited condition removed

No authentication condition

GET /invoices initially inherits the global bearer requirement. Adding security: [] to the operation opens an anonymous acceptance path in the document model.

Expand the old rule
{
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/invoices": {
      "get": {}
    }
  }
}
Expand the new rule
{
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/invoices": {
      "get": {
        "security": []
      }
    }
  }
}

JSON fragments, not complete OpenAPI documents.

GET /export

OAuth still required

The scope goes; OAuth remains

Before

OAuthScheme requirement
AND
read scopeAdditional permission

OAuth and read required

After

OAuthScheme requirement remains
No scope conditionread is no longer required

OAuth required

For GET /export, oauth: [read] becomes oauth: []. The specific read scope requirement is removed, while the OAuth scheme remains. This example is not anonymous.

Expand the old rule
{
  "security": [
    {
      "oauth": [
        "read"
      ]
    }
  ]
}
Expand the new rule
{
  "security": [
    {
      "oauth": []
    }
  ]
}

JSON fragments, not complete OpenAPI documents.

GET /dual

Authentication remains

Joint requirements become alternatives

Before

AScheme requirement
AND
BScheme requirement

Both A and B

After

AFirst alternative
OR
BSecond alternative

Either A or B

For GET /dual, A and B in one object must both be satisfied. In separate objects, either A or B is sufficient. Accepted paths expand, without adding an anonymous path.

Expand the old rule
{
  "security": [
    {
      "A": [],
      "B": []
    }
  ]
}
Expand the new rule
{
  "security": [
    {
      "A": []
    },
    {
      "B": []
    }
  ]
}

JSON fragments, not complete OpenAPI documents.

This visual is a browser walkthrough; it does not run the CLI or a live API.

From two files to a review decision

  1. 01

    Read the old and new JSON/YAML documents.

  2. 02

    Resolve global security inheritance and operation overrides.

  3. 03

    Compare effective AND/OR conditions in both directions.

  4. 04

    Keep justified exceptions visible and return a CI result.

Run locally

python openapi_auth_drift.py examples/before.json examples/after.json --format json

README, LIMITS and tests are included in the ZIP

No open-source license has been selected for this version.

Recorded synthetic example

The JSON and YAML versions of this example produce four findings. A reason for /health leaves three findings for review and one acknowledged; the CI exit code is 1.

REVIEW GET /dual: requirements_relaxed
REVIEW GET /export: scope_reduced
ACKNOWLEDGED GET /health: new_anonymous_operation
REVIEW GET /invoices: anonymous_opened

4 findings · 3 actionable · 1 acknowledged
exit 1

This block is a short summary of a recorded example; the page runs no Python or CLI process.

Verification and supported profile

22 CLI test methods passed on Linux/POSIX, Python 3.14.10 and PyYAML 6.0.3. The separate 150-case preparation review is tied to the same core source hashes; that longer run was not repeated for the clean publication copy.

  • Same-document auth/Path Item JSON Pointers are supported. External-file and remote auth references return exit 2; no references are downloaded.
  • Callback/webhook operations are unsupported and are not silently skipped. General request/response Schema references are not resolved.
  • A bounded YAML SafeLoader profile rejects anchors, aliases and merge keys. File size, nesting, nodes and comparison work are limited.
  • Windows, other Python/PyYAML versions and live API behaviour were not tested. A schema difference is not proof of a live vulnerability.

README ↗ · LIMITS ↗ · Verification ↗

Read the full article ↗

CONTACT

Have a similar need?

Start by sharing the problem, your current system and what you want to achieve.

These buttons open your email app with a prepared subject and message. Nothing is sent until you send it.

Work and project inquiries

GitHub profileInstagram profile