Skip to content

CorsSubdomainWildcardInvalid ​

warning native on by default

Group: Probable bugs

Send a concrete CORS origin.

Example ​

Finding:

php
<?php
header("Access-Control-Allow-Origin: https://*.service.test");

Reported:

  • line 2: Send a concrete CORS origin.

Detection ​

  • Report builtin header setting a literal Access-Control-Allow-Origin value containing star within a serialized origin host or another origin component. The complete value star remains valid.
  • Emit one finding per violating operation. Flow facts require a reachable path with no intervening mutation, escaped alias or unknown call involving the tracked value. When the proof is inconclusive, nothing is reported.

Exceptions (no report) ​

  • Unknown values and a sole star are excluded. Do not apply this rule to unrelated headers that support host patterns.
  • Exclude shadowed builtin symbols, unresolved required types, incomplete syntax and unsupported PHP versions.

Fix ​

No automatic fix. Choosing a repair requires runtime information, error-handling policy or a semantic decision.

PHP versions ​

Available throughout PHP 5.3–8.5.

Configure ​

In custos.json:

json
{
  "rules": {
    "CorsSubdomainWildcardInvalid": {
      "enabled": false
    }
  }
}

Suppress ​

Before the statement or declaration (or the first statement of the file):

php
// @custos-ignore CorsSubdomainWildcardInvalid

Released under the MIT License. Native rules and rules modeled on Php Inspections (EA Extended); independent clean-room implementation.