cwe-287-improper-authentication

Remediates CWE-287 Java vulnerabilities by adding Spring Security @PreAuthorize annotations to controllers.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill addresses vulnerabilities in Java applications where authentication mechanisms are improperly implemented, potentially allowing unauthorized access.

Core Features & Use Cases

  • Vulnerability Identification: Detects insecure authentication patterns in Java code, specifically CWE-287.
  • Deterministic Remediation: Provides a secure, pre-defined code transformation to fix improper authentication issues.
  • Use Case: When a SAST tool flags an endpoint for missing authentication checks, this Skill can be applied to automatically add the necessary Spring Security annotations and checks.

Quick Start

Use the cwe-287-improper-authentication skill to secure the provided Java controller code.

Frequently Asked Questions about cwe-287-improper-authentication

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

FAQPage Schema
How do I fix CWE-287 improper authentication in a Spring Boot controller?

Fix CWE-287 improper authentication by applying Spring Security's @PreAuthorize annotation to Spring Boot controllers, enforcing role-based access control so only authenticated users with correct roles reach sensitive endpoints.

What does the @PreAuthorize annotation do for Java endpoint security?

The @PreAuthorize annotation secures Java endpoints by enforcing role-based access control before method execution, ensuring only authenticated users with correct roles can access sensitive Spring Boot controllers.

How do I add role-based access control to Java controllers flagged by SAST tools?

Add role-based access control to Java controllers by applying Spring Security's @PreAuthorize annotation, which provides deterministic remediation for endpoints flagged by SAST tools for missing authentication checks.

Can I use Spring Security to remediate missing authentication checks in Java applications?

Yes, use Spring Security to remediate missing authentication checks in Java applications by applying the @PreAuthorize annotation to Spring Boot controllers, ensuring only authenticated users with correct roles access sensitive endpoints.

What is the best way to secure sensitive endpoints in Spring Boot lacking proper authorization?

Secure sensitive Spring Boot endpoints lacking proper authorization by applying Spring Security's @PreAuthorize annotation, which enforces role-based access control and remediates CWE-287 improper authentication vulnerabilities.

Why does my Java application have an improper authentication vulnerability?

Java applications have improper authentication vulnerabilities when Spring Boot controllers lack proper authorization, allowing unauthorized access to sensitive endpoints that require authenticated users with correct roles.