spring-projects / spring-projects/spring-security-samples

Missing ownership checks in REST samples detected by Chanakya static analysis

Open
#411 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
1.8k
Forks
797
Avg merge
3m
Merged PRs (30d)
5

Description

Running Chanakya static analyzer on Spring Security
samples reveals several REST endpoints where
@PathVariable IDs flow to repository.findById()
without per-user ownership verification.

These are not Spring Security vulnerabilities —
they are common mistakes in Spring Boot REST APIs
that Spring Security samples could help document.

Example pattern flagged:
@GetMapping("/orders/{id}")
public Order getOrder(@PathVariable Long id) {
return orderRepository.findById(id); // no ownership check
}

Correct pattern:
@PreAuthorize("#id == authentication.principal.id")
OR post-fetch:
if (!order.getOwnerId().equals(currentUser.getId()))
throw new AccessDeniedException();

Would the maintainers be interested in adding a
section documenting this common mistake and its fix?

A01 precision: 0.719 on 65 labeled real-world cases
Contributed by: Suman Lamichhane and Sujana Acharya
Contact: sumanlamichhane45@gmail.com | [sujanaacharya17@gmail.com]

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no files or tests; start by locating the Spring Boot REST samples and the endpoints flagged by Chanakya. Confirm the maintainers' scope for a documentation section covering the ownership mistake and its fixes, then consider the work done when that guidance is added to the relevant sample documentation.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring-boot
Domain
api, security
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.