Safeguard
Application Security•

CWE-649 Obfuscated or Encrypted Inputs Without Integrity Checks

Encrypting or scrambling a client-side token does not stop tampering. Without an integrity check, attackers just search for a value that works in their favor.

Safeguard Security Team
3 min read

CWE-649 is what happens when an application hands the client a token or parameter it should not be changed, hides it with obfuscation or encryption, and then trusts it when it comes back. Confidentiality is not integrity. Scrambling a value says nothing about whether someone altered it. Any web or API service that stores state in cookies, hidden fields, URLs or tokens can be hit.

How it happens

The server puts state on the client: a role, a price, an account number, a workflow step. To keep users from editing it, the developer encodes it, XORs it, or encrypts it, then reads it back on the next request and acts on it.

MITRE explains the attack. The adversary traverses the space of possible values of the token, looking for another admissible value that elevates privileges, discloses information or changes behavior. Even with correct encryption, where the ciphertext reveals nothing about the plaintext, compromising integrity is possible, though less likely, without an integrity service.

A vulnerable pattern in Python:

import base64
# Vulnerable: "hidden" by base64, nothing proves it is unmodified
token = base64.b64encode(b"role=user;id=42").decode()
# attacker sends base64 of role=admin;id=42 and the server accepts it

The record's observed example is CVE-2005-0039: an IPSec configuration that did not perform integrity checking of the packet, either because ESP was not configured to support the integrity service or because AH was used improperly.

What an attacker gains

The consequence MITRE lists is integrity: inputs can be modified without detection, causing unexpected system state or incorrect security decisions. In practice that can be privilege changes or altered business values, depending on what the token controls.

How to find it

Look at every value the server issues and later trusts: cookies, hidden form fields, query parameters, JWT-like tokens, serialized state. Ask whether the server verifies a signature or MAC on it. A manual test is simple: decode or flip bytes in the token and resend it. If the server accepts a modified value, or returns an error that reveals structure, integrity is missing. Static analysis may flag some reads of client-controlled values used in security decisions.

How to fix it

MITRE's mitigations, in plain steps:

  1. Protect important client-controllable tokens and parameters for integrity using digital signatures or other means, and check them on the server side.
  2. Treat repeated invalid values as an attack. Repeated requests from a user carrying tokens that should not be changed manually should result in account lockout.
  3. Make client-side values hard to guess, so another valid state is not easy to find.
  4. Do not rely on obfuscation. If you use encryption, apply it properly: a proven algorithm and implementation, padding, a random initialization vector and a proper mode. Even then, add the integrity service.
import hmac, hashlib
SECRET = load_server_secret()

def sign(data: bytes) -> str:
    return hmac.new(SECRET, data, hashlib.sha256).hexdigest()

def verify(data: bytes, mac: str) -> bool:
    return hmac.compare_digest(sign(data), mac)

The simplest design is to keep the state on the server and give the client only an opaque random session ID.

Quick check

If I encrypt the token, is it protected from tampering?

Not necessarily. Encryption protects confidentiality. MITRE says measures used for confidentiality should not be relied on to provide integrity.

What does a server need to detect tampering?

A signature or MAC verified server side, made with a key the client never sees.

Sources

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.