Safeguard
Application Security•

CWE-421 Race Condition During Access to Alternate Channel

A channel opened for one user can be grabbed by another if it is reachable before the right user connects. CWE-421 and the fix.

Safeguard Security Team
2 min read

CWE-421 is a product that opens an alternate channel to talk to an authorized user, but leaves that channel reachable by other actors. This creates a race: whoever connects first wins.

How it happens

A service opens a second port or pipe, tells the user where it is, and waits. Between opening and the legitimate connection, an attacker connects to it.

MITRE lists two examples. In the FTP "Pizza Thief" issue, an attacker could connect to a port intended for another client (CVE-1999-0351). In another product, a Windows named pipe created during authentication could be hijacked by an attacker connecting to it (CVE-2003-0230).

What an attacker gains

Per the record: gaining privileges or assuming identity, and bypassing protection mechanisms.

How to find it

The record has no detection methods. Check manually:

  • Find every place the code opens a listener, pipe or port for a specific peer.
  • Ask whether the channel verifies that the connecting party is the expected one.

How to fix it

  1. Authenticate the peer on the alternate channel, not only the first one.
  2. Restrict who can connect, for example with pipe access controls or a source address check.
  3. Use unpredictable names and tokens for the channel, and accept only one connection.
  4. Prefer a single channel when you can.

Why the window is short but real

The gap between opening a channel and the right user connecting may be milliseconds. Attackers do not need to be precise. They can poll for the port or pipe, or connect in a loop, and win the race some of the time. Predictable names and port numbers make this easy. Random, single use identifiers and an authentication step on the second channel remove the advantage.

Quick check

What makes this a race?

The channel exists before its intended user arrives. Anyone who connects in that window can take it.

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.