Back to skill

Security audit

Java Design Patterns

Security checks for vulnerabilities and agentic risk

Overview

This is a Java design-pattern reference skill with some weak or unsafe example code, but no evidence of hidden execution, exfiltration, persistence, or destructive behavior.

Install only as a reference aid, not as production-ready code. Review generated recommendations carefully before copying examples into real systems, especially anything involving money, logging, credentials, request bodies, JSP rendering, concurrency, or external API calls. Do not run the included scripts unless you first inspect and adjust their hardcoded local paths.

Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (22)

Intent-Code Divergence

Medium
Confidence
96% confidence
Finding
This is a true issue because the documentation explicitly claims the example avoids floating-point inaccuracies, yet the implementation stores currency in a double and applies manual rounding. In financial code, this can produce cumulative precision errors, inconsistent balances, and developer misuse if readers copy the example into production systems believing it is safe for money handling.

Intent-Code Divergence

Low
Confidence
84% confidence
Finding
This is a real documentation/code inconsistency: the page presents the pattern as immutable/value-object oriented, but the sample mutates amount and currency in place. That mismatch can mislead developers about thread-safety, reasoning about side effects, and value-object semantics, making misuse more likely in systems that depend on immutability guarantees.

Intent-Code Divergence

Medium
Confidence
95% confidence
Finding
The documentation states that the Null Object pattern eliminates null checks and avoids null-related errors, but the provided NullNode implementation returns actual null values from getLeft(), getRight(), and getName(). This breaks the core guarantee of the pattern and can mislead users into writing code that dereferences these values, causing NullPointerExceptions or inconsistent behavior when the example is adapted outside the narrow demonstrated path.

Context-Inappropriate Capability

Medium
Confidence
97% confidence
Finding
The sample output contains production-like email addresses and bank account numbers in a general reference document, which can normalize unsafe handling of sensitive data and may disclose realistic identifiers if copied from real systems. Even if illustrative, exposing such data in documentation increases privacy, compliance, and accidental reuse risks, especially in a skill that may be surfaced directly to users or downstream agents.

Intent-Code Divergence

Medium
Confidence
96% confidence
Finding
The documentation states that the Null Object pattern eliminates null handling, but the provided `NullNode` returns actual `null` from `getLeft()`, `getRight()`, and `getName()`. This undermines the pattern’s safety guarantees and can mislead users into writing code that assumes null-safe behavior, potentially causing `NullPointerException`s or unsafe downstream logic in real applications.

Intent-Code Divergence

Medium
Confidence
95% confidence
Finding
The example is presented as Double-Checked Locking, but the method is declared synchronized, which serializes every call and defeats the stated performance benefit. In a design-pattern reference skill, this can mislead users into copying an incorrect concurrency pattern, causing performance regressions and confusion about thread-safety guarantees; it also omits the usual volatile requirement associated with correct DCL implementations.

Intent-Code Divergence

Medium
Confidence
97% confidence
Finding
The documentation explicitly claims the example avoids floating-point inaccuracies, but the implementation uses `double` and manual rounding, which are unsuitable for precise monetary arithmetic. In a design-pattern reference skill, this can mislead users into copying financially unsafe code into production systems, causing rounding drift, incorrect balances, or accounting discrepancies.

Intent-Code Divergence

Medium
Confidence
91% confidence
Finding
The page frames Money as a value-object style pattern, but the sample mutates `amount` and `currency` in place through methods like `addMoney`, `subtractMoney`, `multiply`, and `exchangeCurrency`. This mismatch is dangerous because consumers may assume immutability and safe sharing across threads or components, leading to subtle logic bugs, stale state assumptions, and race-condition-prone usage in financial code.

Vague Triggers

Medium
Confidence
92% confidence
Finding
The trigger conditions are broad enough to match common terms like '如何实现', architecture discussions, code review, and software design principles, which can cause the skill to activate outside narrow user intent. Over-broad invocation can bias agent behavior, unexpectedly inject large skill context, and crowd out safer or more relevant skills, increasing prompt-surface and the chance of unintended actions or misleading answers.

Missing User Warnings

Low
Confidence
95% confidence
Finding
The example reads a user-controlled `name` parameter from the HTTP request and renders it directly in JSP using `<%= propertiesBean.getName()%>` without output encoding. In a JSP/servlet context, this can lead to reflected cross-site scripting if an attacker supplies HTML or JavaScript in the `name` parameter, and the documentation does not warn readers about safe output handling, increasing the chance the insecure pattern will be copied into real applications.

Missing User Warnings

Medium
Confidence
90% confidence
Finding
The sample log output includes what appear to be real-style email addresses and bank account numbers, normalizing exposure of personal and financial data in logs. Even if illustrative, publishing this without anonymization or an explicit warning can encourage insecure logging practices and may leak sensitive data if copied into real systems, documentation, demos, or training material.

Missing User Warnings

Medium
Confidence
98% confidence
Finding
The console output logs full User objects and explicitly includes plaintext passwords, which normalizes insecure handling of credentials and can lead to credential exposure in logs if copied into real systems. In the context of a design-pattern reference, this is more dangerous because readers may reuse the sample verbatim without noticing that sensitive data is being printed.

Missing User Warnings

Medium
Confidence
90% confidence
Finding
The document promotes distributed tracing and correlated logging but does not warn that traces, tags, spans, and logs can capture personal data, auth tokens, internal identifiers, or business-sensitive payloads. In an observability context, copied telemetry often flows into centralized backends and broader operator access domains, so omission of data-minimization guidance can lead to privacy exposure and unintended data retention.

Missing User Warnings

Medium
Confidence
97% confidence
Finding
The sample code logs raw inbound request bodies in the order, payment, and product controllers, which can expose user-supplied data directly into application logs and downstream tracing systems. In a microservices observability tutorial, readers may copy this pattern into production, where sensitive payment, order, or product-related data could be retained, searched, exported, or accessed by unauthorized staff.

Missing User Warnings

Medium
Confidence
88% confidence
Finding
This content recommends suppressing exceptions during resource cleanup and frames close failures as non-critical, which can normalize unsafe error-handling practices. In real systems, suppressed cleanup exceptions may hide resource leaks, failed flush/sync operations, or repeated operational faults, especially if readers copy the pattern without strong caveats.

Missing User Warnings

Medium
Confidence
85% confidence
Finding
The example logs authentication-like tokens and user account information directly, which can normalize unsafe logging practices and lead downstream users to copy code that exposes sensitive data in application logs. In real systems, tokens can enable session hijacking or user correlation, and account details in logs can create privacy and compliance risks.

Missing User Warnings

Medium
Confidence
95% confidence
Finding
The example console output logs full User objects including plaintext passwords, which normalizes unsafe handling of credentials and may lead developers to copy this pattern into real systems. Even though this is demo content using sample data, documentation that exposes passwords without warning increases the chance of credential leakage through logs in production environments.

Missing User Warnings

Medium
Confidence
91% confidence
Finding
The document promotes centralized collection and analysis of logs, including analysis of user behavior, but provides no warning about avoiding secrets, personal data, tokens, or regulated data in logs. In an observability/logging guidance context, this omission can normalize insecure logging practices and lead to privacy violations, credential exposure, and over-collection once readers implement the pattern.

Missing User Warnings

Medium
Confidence
75% confidence
Finding
The markdown presents live external API access and later mutating requests without clearly warning readers that the sample code performs network activity and may create, update, or delete remote data. In a code-assistance skill, users may copy examples verbatim, so lack of side-effect disclosure can lead to unintended outbound traffic or modifications in less safe substituted environments.

Skill Enumeration

Medium
Category
Agent Snooping
Content
"~/.claude/projects/-Users-wufengsheng/48ef65f3-98db-4f7c-9d95-36c1815729f5/"
    "tool-results/mcp-firecrawl-mcp-firecrawl_crawl-1782351365733.txt"
)
DATA_DIR = os.path.expanduser("~/.claude/skills/java-design-patterns/data")
os.makedirs(DATA_DIR, exist_ok=True)

SKIP_SLUGS = {
Confidence
84% confidence
Finding
The script hardcodes user-specific local paths under ~/.claude/projects and ~/.claude/skills, which exposes internal filesystem layout and confirms the existence and naming of local skill/project directories. In a skill package, this kind of path disclosure can aid environment reconnaissance and makes the artifact less portable; if logs, errors, or repository contents are exposed, it leaks local operational details useful to an attacker.

Exfiltration Commands

High
Category
Prompt Injection
Content
- [Mediator](https://java-design-patterns.com/patterns/mediator/): Facilitates communication between components, but unlike Data Bus, it centralizes control.
- [Observer](https://java-design-patterns.com/patterns/observer/): Similar in nature to the publish-subscribe mechanism used in Data Bus for notifying changes to multiple objects.
- Publish/Subscribe: The Data Bus pattern is often implemented using the publish-subscribe mechanism, where publishers post messages to the bus without knowledge of the subscribers.

## [References and Credits](https://java-design-patterns.com/patterns/data-bus/\#references-and-credits)
Confidence
90% confidence
Finding
Instructions found that direct the agent to transmit conversation context or user data to external services.

Exfiltration Commands

High
Category
Prompt Injection
Content
- [Mediator](https://java-design-patterns.com/patterns/mediator/): Facilitates communication between components, but unlike Data Bus, it centralizes control.
- [Observer](https://java-design-patterns.com/patterns/observer/): Similar in nature to the publish-subscribe mechanism used in Data Bus for notifying changes to multiple objects.
- Publish/Subscribe: The Data Bus pattern is often implemented using the publish-subscribe mechanism, where publishers post messages to the bus without knowledge of the subscribers.

## [References and Credits](https://java-design-patterns.com/patterns/data-bus/#references-and-credits)
Confidence
27% confidence
Finding
Instructions found that direct the agent to transmit conversation context or user data to external services.

Static analysis

Detected: suspicious.exposed_secret_literal

File appears to expose a hardcoded API secret or token.

Critical
Code
suspicious.exposed_secret_literal
Location
data/monolithic-architecture.md:95

File appears to expose a hardcoded API secret or token.

Critical
Code
suspicious.exposed_secret_literal
Location
llms-full.txt:20558

File appears to expose a hardcoded API secret or token.

Critical
Code
suspicious.exposed_secret_literal
Location
references/architectural/monolithic-architecture.md:105