CWE-1235 Base Incomplete

Incorrect Use of Autoboxing and Unboxing for Performance Critical Operations

This weakness occurs when a program relies on automatic boxing and unboxing of primitive types within performance-sensitive code sections, causing unnecessary computational overhead and potential…

Definition

What is CWE-1235?

This weakness occurs when a program relies on automatic boxing and unboxing of primitive types within performance-sensitive code sections, causing unnecessary computational overhead and potential resource strain.
Languages like Java and C# provide autoboxing (converting a primitive like `int` to an object like `Integer`) and unboxing (the reverse) to simplify code by handling conversions automatically. While convenient for general use, these operations secretly create new objects and add processing steps that degrade execution speed, especially inside tight loops or high-frequency operations. Using boxed primitives within generic collections or performance-critical areas—such as scientific computing, real-time processing, or low-latency systems—can lead to excessive memory allocation, increased garbage collection, and even resource exhaustion. This practice is best reserved only for bridging the gap between primitive APIs and object-based libraries, not for core computational logic where efficiency is paramount.
Auswirkungen in der Praxis

Real-world CVEs caused by CWE-1235

Bisher sind in MITREs Katalog keine öffentlichen CVE-Referenzen mit dieser CWE verknüpft.

Wie Angreifer es ausnutzen

Angreiferpfad Schritt für Schritt

  1. 1

    Java has a boxed primitive for each primitive type. A long can be represented with the boxed primitive Long. Issues arise where boxed primitives are used when not strictly necessary.

  2. 2

    In the above loop, we see that the count variable is declared as a boxed primitive. This causes autoboxing on the line that increments. This causes execution to be magnitudes less performant (time and possibly space) than if the "long" primitive was used to declare the count variable, which can impact availability of a resource.

  3. 3

    This code uses primitive long which fixes the issue.

Verwundbares Codebeispiel

Vulnerable Java

Java has a boxed primitive for each primitive type. A long can be represented with the boxed primitive Long. Issues arise where boxed primitives are used when not strictly necessary.

Verwundbar Java
Long count = 0L; 
   for (long i = 0; i < Integer.MAX_VALUE; i++) { 
  	 count += i; 
   }
Sicheres Codebeispiel

Secure Java

This code uses primitive long which fixes the issue.

Sicher Java
long count = 0L; 
   for (long i = 0; i < Integer.MAX_VALUE; i++) { 
  	 count += i; 
   }
What changed: the unsafe sink is replaced (or the input is validated/escaped) so the same payload no longer triggers the weakness.
Präventions-Checkliste

How to prevent CWE-1235

  • Implementation Use of boxed primitives should be limited to certain situations such as when calling methods with typed parameters. Examine the use of boxed primitives prior to use. Use SparseArrays or ArrayMap instead of HashMap to avoid performance overhead.
Erkennungssignale

How to detect CWE-1235

SAST High

Führe statische Analyse (SAST) auf der Codebasis aus und suche im Datenfluss nach dem unsicheren Muster.

DAST Moderate

Führe dynamische Application-Security-Tests gegen den Live-Endpoint aus.

Runtime Moderate

Beobachte Runtime-Logs auf ungewöhnliche Exception-Traces, fehlerhafte Eingaben oder Versuche, Autorisierung zu umgehen.

Code review Moderate

Code Review: Markiere jeden neuen Code, der Eingaben von dieser Oberfläche ohne validierte Framework-Helper verarbeitet.

Plexicus Auto-Fix

Plexicus erkennt CWE-1235 automatisch und öffnet in unter 60 Sekunden einen Fix-PR.

Codex Remedium scannt jeden Commit, identifiziert genau diese Schwachstelle und liefert einen reviewer-ready Pull Request mit dem Patch. Keine Tickets. Keine Hand-offs.

Häufig gestellte Fragen

Frequently asked questions

Was ist CWE-1235?

This weakness occurs when a program relies on automatic boxing and unboxing of primitive types within performance-sensitive code sections, causing unnecessary computational overhead and potential resource strain.

Wie gravierend ist CWE-1235?

MITRE hat für diese Schwachstelle keine Exploit-Wahrscheinlichkeit veröffentlicht. Behandle sie als mittlere Auswirkung, bis dein Threat Model anderes belegt.

Welche Sprachen oder Plattformen sind von CWE-1235 betroffen?

MITRE lists the following affected platforms: Java, C#, Not OS-Specific, Not Architecture-Specific, Not Technology-Specific.

Wie kann ich CWE-1235 verhindern?

Use of boxed primitives should be limited to certain situations such as when calling methods with typed parameters. Examine the use of boxed primitives prior to use. Use SparseArrays or ArrayMap instead of HashMap to avoid performance overhead.

Wie erkennt und behebt Plexicus CWE-1235?

Die SAST-Engine von Plexicus erkennt die Datenfluss-Signatur von CWE-1235 bei jedem Commit. Bei einem Treffer öffnet unser Codex-Remedium-Agent einen Fix-PR mit korrigiertem Code, Tests und einer einzeiligen Zusammenfassung für den Reviewer.

Wo erfahre ich mehr über CWE-1235?

MITRE veröffentlicht die kanonische Definition unter https://cwe.mitre.org/data/definitions/1235.html. Für ergänzende Hinweise kannst du auch die OWASP- und NIST-Dokumentation heranziehen.

Bereit, wenn du es bist

Schluss mit dem Bezahlen pro Entwickler.
Schließ den Kreislauf.

Plexicus ist die KI-native ASPM, die scannt, filtert, fixt, pentestet und erklärt — autonom. Unbegrenzte Entwickler, unbegrenzte Repos, Fair-Use-KI-Aktionen. Echter kostenloser Tarif, €269/mo jährlich, wenn du bereit bist.