What Is CWE-1287? Input Type Validation Explained
Security Beginner 6 min read

What Is CWE-1287? Input Type Validation Explained

CWE-1287 is improper validation of input type. See how an empty JSON object bypassed Xen Orchestra login and how to find the same flaw in your own apps.

Published: November 29, 2026 • Updated: November 29, 2026
cwe-1287input validationauthenticationweb security

CWE-1287, Improper Validation of Specified Type of Input, is the weakness behind the Xen Orchestra authentication bypass that CISA added to its exploited list on 2026-11-25. The code expected a string token and received a JSON object instead. Nothing checked the type, so an empty object turned into a wildcard database lookup and logged the attacker in as whoever owned the first stored token. This article explains what CWE-1287 covers, why web frameworks make it easy to trigger, and how to find the same pattern in your own applications.

What is CWE-1287?

CWE-1287 is the MITRE weakness category for code that receives input expected to be of a certain type but does not verify that the input actually has that type. The classic result is a function that was written for a string, number or boolean behaving in an unplanned way when it gets an object, an array or null.

In JavaScript, Python, PHP and Ruby, the runtime will pass an object where a string was expected and let the downstream code sort it out. The downstream code usually does not. It calls a method, compares a value or builds a query, and the result depends on how that language treats the unexpected type.

CWE-20 (improper input validation) is the parent weakness. CWE-843 (type confusion) covers the memory-unsafe version in C and C++, where a pointer to one type is used as another. CWE-1287 is the application-level version: the memory is fine, the logic is wrong.

How did an empty object bypass Xen Orchestra authentication?

The Xen Orchestra REST API read its login token from a cookie. The Express cookie-parser middleware decodes any cookie value that starts with the prefix j: as JSON, so a crafted cookie arrived as an empty object rather than a token string. The authentication provider only checked that the value was truthy, which an empty object is, and passed it to the token store. The store treated an empty filter object as "match everything" and returned the first token, and the provider authenticated the request as that token's owner.

Every step in that chain is individually reasonable: a documented JSON cookie feature, a normal guard against missing values, and a data layer that returns everything for an empty filter. The vulnerability lives in the gap between them: no component confirmed that the value was a string before the value changed meaning.

The GitHub advisory for CVE-2026-133469 points out the exact omission. The deprecated sign-in method declared its token parameter as type string in a schema. The newer method had no schema at all. The fix adds the type requirement back. The full story, including the second unfixed flaw and the indicators Vates published, is in the news report on the Xen Orchestra KEV listing.

Why do web frameworks make CWE-1287 easy to trigger?

Web frameworks parse untyped text from the network into convenient native structures, and the parsing rules are often richer than developers assume. Query string parsers turn repeated parameters into arrays and bracket notation into nested objects, body parsers decode JSON into arbitrary structures, and some cookie parsers decode JSON too. Code written with a single string value in mind is reachable with any of those shapes.

The common cases to look for:

  • Query string arrays. ?id=1&id=2 becomes an array in many frameworks. A lookup written as where id = :id may behave differently with an array, and a string comparison against an array silently fails or coerces.
  • Bracket notation to objects. ?user[admin]=true becomes {user: {admin: "true"}} in Express with the extended query parser, in PHP, and in Rack. This is the mechanism behind many mass-assignment bugs.
  • JSON body type swaps. A JSON body field documented as a string can be sent as an object, array, number or null. If the handler forwards it into a database driver, an object may become a query operator. MongoDB operator injection through {"$ne": null} is the best-known example and is the same weakness class as the Xen Orchestra bug.
  • JSON cookies. Express cookie-parser's j: prefix, used by Xen Orchestra, is one example. Other frameworks have signed or serialized cookie formats with similar behavior.
  • Prototype or reserved keys. Keys such as __proto__ or constructor in parsed objects can alter behavior when merged into other objects. This is adjacent to CWE-1287 and is usually catalogued as CWE-1321.

In each case the data layer is doing what it was designed to do. The failure is that the boundary code never pinned the type down.

How do you prevent CWE-1287 in your own applications?

Validate the type of every externally supplied value at the point it enters the application, before any business logic or data access sees it. Use a schema library that rejects wrong types rather than coercing them, and treat an unexpected type as a hard error, not a value to be cleaned up.

Concrete practices that would have stopped the Xen Orchestra bug and most of its relatives:

  1. Schema on every entry point. Declare request parameters with a validator (JSON Schema, Zod, Joi, Pydantic, Marshmallow or the framework's equivalent) and fail closed when the shape is wrong. Xen Orchestra's deprecated method had a schema; the replacement did not. Audit for handlers that lost their schema during a refactor.
  2. Explicit type assertions in authentication code. Authentication and authorization paths deserve a second, local check even when a schema exists upstream: typeof token !== "string" and reject. These paths are where a wrong type costs the most.
  3. Never pass user input directly as a query filter. Build the filter yourself from validated scalars. An empty object, an array or an operator-bearing object should never be able to reach the data layer as a filter.
  4. Disable parser features you do not use. Turn off extended query parsing, JSON cookie decoding or nested body parsing where the application does not need them. Less transformation at the edge means fewer surprise shapes inside.
  5. Test with wrong types, not just wrong values. Fuzzing and unit tests usually vary the value of a field. Add cases that vary the type: object, array, empty object, empty array, null, number. The Xen Orchestra finders used exactly this approach.
  6. Log the rejection. Vates noted that a successful bypass left no log entry. A validation failure on an authentication parameter should log the source address and the parameter name, because that log line is your only detection signal when the check is the thing being attacked.

Why does CWE-1287 keep appearing in management software?

Infrastructure management tools are long-lived codebases with multiple API generations (JSON-RPC, REST, WebSocket) layered on top of a shared authentication core. Each new API layer parses input differently, and the core was written for the oldest one. That mismatch is where type assumptions break.

Xen Orchestra is a good example: the token provider was shared by the legacy JSON-RPC sign-in and the newer REST middleware, and the REST path introduced JSON cookie decoding that the provider never anticipated. The same architecture exists in most virtualization, backup and network management products. When you review one of these systems, trace each input from its parser to the authentication core and ask at each hop whether the type is still guaranteed. The companion piece on why VM import privilege equals hypervisor admin covers the other half of this incident: what happened once the type check failed and an attacker held an Admin session on the management plane.