Safeguard
Application Security•

CWE-774 Allocating File Descriptors Without Limits or Throttling

A server that opens a descriptor for every request with no cap lets one client starve the rest. See the limits and throttles that prevent it.

Safeguard Security Team
2 min read

CWE-774 covers products that allocate file descriptors or handles on behalf of an actor without restricting how many that actor can get. It is a specific case of the broader CWE-770.

Network services and anything that accepts uploads or opens files for users are the main targets.

How it happens

Each connection, upload or request opens a descriptor. If nothing caps the number per user or per process, a single client can open thousands and keep them open.

What an attacker gains

The record lists availability. All descriptors get consumed, and other processes cannot perform critical file operations. No code execution is needed, only patience and a script.

How to find it

Static analysis can find some cases, according to MITRE. A quick practical test is to open many connections from one client against a staging copy and see whether the service keeps answering others.

How to fix it

  1. Use resource limits from the operating system or environment. MITRE names setrlimit() and getrlimit() on POSIX.
  2. Set per user and per connection caps in the application too, so one actor cannot take the whole pool.
  3. As usage approaches the maximum, limit further allocation to privileged users, or release descriptors held by less privileged ones.
  4. Handle allocation failures with proper error checks.

Quick check

Why is a process-wide limit alone not enough?

It protects the system but not your other users. One client can still use up the whole allowance, so add per client caps.

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.