cwe-306-missing-authentication

Implement Spring Security authentication checks for critical Java functions.

3|1|Updated Mar 6, 2026
One-click install
npx skills add https://github.com/DevelopersCoffee/java-cwe-security-skills --skill cwe-306-missing-authentication
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cwe-306-missing-authentication
Source: https://github.com/DevelopersCoffee/java-cwe-security-skills/tree/main/cwe-306-missing-authentication
Command: npx skills add https://github.com/DevelopersCoffee/java-cwe-security-skills --skill cwe-306-missing-authentication

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill addresses the critical security vulnerability of Missing Authentication for Critical Functions in Java applications, ensuring that sensitive operations are protected.

Core Features & Use Cases

  • Vulnerability Remediation: Identifies and fixes code patterns where critical functions lack proper authentication.
  • Secure Implementation: Provides a deterministic fix using Spring Security annotations like @PreAuthorize and @AuthenticationPrincipal.
  • Use Case: When a SAST tool flags a deleteUser endpoint as vulnerable due to missing authentication, this skill can be applied to automatically add the necessary role-based access control and user principal checks.

Quick Start

Use the cwe-306-missing-authentication skill to secure the critical function in the provided Java controller code.

Frequently Asked Questions about cwe-306-missing-authentication

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix CWE-306 missing authentication for critical functions in Java?

Fix missing authentication in Java by applying role-based access control using Spring Security annotations like @PreAuthorize and @AuthenticationPrincipal. These checks secure sensitive controller and service operations against unauthorized access.

What is missing authentication for critical functions in Java applications?

Missing authentication for critical functions occurs when sensitive operations like user deletion lack proper access validation. This vulnerability allows unauthorized users to execute privileged actions within the application's controller or service layers.

How do I add role-based access control to a Spring Boot controller?

Add role-based access control to a Spring Boot controller by applying @PreAuthorize annotations to critical endpoints. This ensures only authenticated users with specific roles can execute sensitive operations like user management functions.

Does this authentication remediation approach work with SAST findings?

Yes, this authentication remediation approach works directly with SAST findings. It targets vulnerabilities identified by Static Application Security Testing tools and automatically implements the necessary authentication checks and access controls.

Do I need Spring Security to remediate missing authentication vulnerabilities?

Spring Security is required to remediate missing authentication vulnerabilities using this approach. The implementation relies on Spring Security annotations like @PreAuthorize and @AuthenticationPrincipal to enforce role-based access control.

When should I use @PreAuthorize versus @AuthenticationPrincipal for securing endpoints?

Use @PreAuthorize to enforce role-based access control on critical endpoints, and use @AuthenticationPrincipal to validate the authenticated user's identity. Both annotations work together to secure sensitive Java controller operations.