← Java / Spring · Contents

JAVA-010 / Intermediate

Exposing entity privilege fields without @Column(updatable)

A01:2021 Broken Access Control · CWE-915 Mass Assignment

Why is this a problem?

Calling save(entity) overwrites role.

How to fix it

java
@Column(updatable = false) private String role;   // Alternatively, restrict privilege changes to dedicated methods and policies

Further reading