This vulnerability occurs when an application fails to accurately track its own operational state. The system incorrectly assumes it's in one mode or condition when it's actually in another, leading to security-critical actions being performed with the wrong assumptions.
Think of this flaw as a developer forgetting to lock a door because they mistakenly believe it's already locked. The application maintains internal flags, variables, or conditions that represent its state—like "authenticated," "processing transaction," or "in admin mode." When the code doesn't properly validate transitions between these states or allows state variables to become inconsistent, the application can perform dangerous operations based on an outdated or incorrect self-perception. For example, it might grant privileged access because a flag wasn't cleared after a logout, or process a user's data as if it were still in a validated session. To prevent this, developers must treat state management as a critical security function. Implement explicit state machines with clear transitions, invalidate state variables immediately when conditions change, and never trust a single flag in isolation. Always perform a fresh, consolidated check of all relevant conditions before executing security-sensitive operations, ensuring the application's internal view of itself always matches reality.
Impact: Varies by ContextUnexpected State