---
title: "CWE-487: Reliance on Package-level Scope"
url: https://radicalnotion.ai/cwe/cwe-487
type: cwe
description: "Java packages are not inherently closed; therefore, relying on them for code security is not a good practice."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-487: Reliance on Package-level Scope

- **Abstraction:** Base
- **Structure:** Simple
- **Status:** Incomplete
- **Likelihood of exploit:** Medium
- **CVEs with this as primary weakness:** 0
- **Of those, in CISA KEV:** 0
- **New in 2026:** 0
- **CWE catalog version:** 4.21

## Description

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

## Background

The purpose of package scope is to prevent accidental access by other parts of a program. This is an ease-of-software-development feature, but not a security feature.

## Modes of introduction

| Phase | Note |
| --- | --- |
| Implementation | - |

## Applicable platforms

**Languages:** Java (Undetermined)

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| 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.)

## Demonstrative examples

### Example 1

The following example demonstrates the weakness.

Bad code:

```java
package math;
public class Lebesgue implements Integration{
    public final Static String youAreHidingThisFunction(functionToIntegrate){

        return ...;
    }
}
```

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-664](https://radicalnotion.ai/cwe/cwe-664) | Improper Control of a Resource Through its Lifetime |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| CLASP | Relying on package-level scope | - | - |
| The CERT Oracle Secure Coding Standard for Java (2011) | Do not increase the accessibility of overridden or hidden methods | MET04-J | - |

## Frequently asked questions

### What is CWE-487?

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

### How do you prevent CWE-487?

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

### How is CWE-487 detected?

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

### What are the consequences of CWE-487?

Exploiting CWE-487 can lead to: Read Application Data, Modify Application Data.

Primary source: [MITRE CWE](https://cwe.mitre.org/data/definitions/487.html)

---

Source: [RadicalNotion.AI](https://radicalnotion.ai/cwe/cwe-487). Licensed CC BY-NC 4.0; attribute RadicalNotion.AI and link the source page when you reuse this data.
