CWEweakness

CWE-487 Reliance on Package-level Scope

Medium Official page ↗
Abstraction
Base
Structure
Simple
Status
Incomplete
Likelihood of exploit
Medium
Languages
Java
CWE version
5.0

Description

Java packages are not inherently closed; therefore, relying on them for code security is not a good practice.

Common consequences

• Confidentiality: Read Application Data — Any data in a Java package can be accessed outside of the Java framework if the package is distributed. • Integrity: Modify Application Data — The data in a Java class can be modified by anyone outside of the Java framework if the package is distributed.

Potential mitigations

• [Architecture and Design, Implementation] Data should be private static and final whenever possible. This will assure that your code is protected by instantiating early, preventing access and tampering.

Detection methods

• 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.)

Related

Child of · CWE (1)

  • CWE-664 Improper Control of a Resource Through its Lifetime weakness