CWE-492: Use of Inner Class Containing Sensitive Data

Variant Draft Simple

CWE版本: 4.18

更新日期: 2025-09-09

弱点描述

Inner classes are translated into classes that are accessible at package scope and may expose code that the programmer intended to keep private to attackers.

扩展描述

Inner classes quietly introduce several security concerns because of the way they are translated into Java bytecode. In Java source code, it appears that an inner class can be declared to be accessible only by the enclosing class, but Java bytecode has no concept of an inner class, so the compiler must transform an inner class declaration into a peer class with package level access to the original outer class. More insidiously, since an inner class can access private fields in its enclosing class, once an inner class becomes a peer class in bytecode, the compiler converts private fields accessed by the inner class into protected fields.

常见后果

影响范围: Confidentiality

技术影响: Read Application Data

说明: "Inner Classes" data confidentiality aspects can often be overcome.

潜在缓解措施

阶段: Implementation

描述: Using sealed classes protects object-oriented encapsulation paradigms and therefore protects code from being extended in unforeseen ways.

阶段: Implementation

描述: Inner Classes do not provide security. Warning: Never reduce the security of the object from an outer class, going to an inner class. If an outer class is final or private, ensure that its inner class is private as well.

检测方法

方法: Automated Static Analysis

Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)

有效性: High

引入模式

阶段 说明
Implementation -

适用平台

编程语言
Java (Undetermined)

分类映射

分类名称 条目ID 条目名称 映射适配度
7 Pernicious Kingdoms - Mobile Code: Use of Inner Class -
CLASP - Publicizing of private data when using inner classes -
The CERT Oracle Secure Coding Standard for Java (2011) OBJ08-J Do not expose private members of an outer class from within a nested class -
关键信息

CWE ID: CWE-492

抽象级别: Variant

结构: Simple

状态: Draft

利用可能性: Medium

相关弱点