Safeguard
Application Security•

CWE-1086 Classes With Too Many Child Classes

CWE-1086 flags a class with an unnecessarily large number of children. Wide inheritance trees are hard to understand and risky to change.

Safeguard Security Team
2 min read

CWE-1086, Class with Excessive Number of Child Classes, applies to object oriented code where one class has an unnecessarily large number of children.

MITRE notes that the number depends on the team. The CISQ standard recommends a default maximum of 10 child classes. The entry is a quality issue with no direct security implications and is prohibited for mapping real vulnerabilities.

How it happens

A base class becomes the place to hang every variation. A Handler with forty subclasses is the usual picture. Each new case adds a child instead of prompting a rethink of the design.

What an attacker gains

Nothing directly. MITRE lists reduced maintainability and increased analytical complexity. A change to the parent affects every child, so a fix to one behavior can quietly alter dozens of others. That makes security fixes riskier and slower.

How to find it

Code metrics tools report the number of children per class. A short script over your class hierarchy can do the same.

How to fix it

  • Prefer composition over inheritance, so variations are plugged in rather than subclassed.
  • Group children under intermediate classes that capture shared behavior.
  • Replace some subclasses with data or configuration when only values differ.
  • Add tests around the parent before changing it.

Quick check

Why does a wide inheritance tree affect security?

A change to the parent reaches every child, so fixes are harder to reason about. The effect is indirect, which is why MITRE treats it as a quality issue.

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.