# GHSA-9P7H-4696-WRGG: Unsafe reflection in the permissions endpoint lets any authenticated user load and initialize arbitrary classes

- Database: GitHub
- Severity: CVSS 5.4 (Medium)
- Published: 2026-10-29
- Modified: 2026-10-29

## Affected versions

- com.ritense.valtimo:authorization (Maven): from 12.0.0, fixed in 13.42.0

## Description

## Summary

`POST /api/v1/permissions` passes the request body's `resource` string directly to
single-argument `Class.forName(String)` with no allowlist. The route is gated only by
`.authenticated()`, unlike every sibling permission- and role-management route under
`/api/management/v1/*`, which all require the `ADMIN` authority.

Per JLS §12.4.1, single-argument `Class.forName(String)` **initializes** the class before
returning, so the static initializer (`<clinit>`) of any class on the application classpath
runs. The surrounding `try/catch` is a post-sink guard: it fires only after the class has
already been loaded and initialized.

```
POST /api/v1/permissions
Authorization: Bearer <any authenticated non-admin token>
Content-Type: application/json

[{"resource":"<any.fully.qualified.ClassName>","action":"view"}]
```

## Impact

Two effects, both available to any signed-in user regardless of role:

1. **Arbitrary class load and static-initializer execution.** Any class on the classpath can be
   loaded and its `<clinit>` run. There is no `newInstance()` or constructor invocation on this
   path, so this is **not** turnkey remote code execution.
2. **Classpath enumeration oracle.** Loadable and non-loadable class names are distinguishable
   through the response and through error/timing behaviour, allowing an attacker to enumerate
   which libraries and versions are present.

The asymmetry is the core of the issue: every neighbouring permission-management route is
admin-locked, while this class-loading primitive is reachable by any authenticated user.

## Affected component

- Module `com.ritense.valtimo:authorization`
- `PermissionResource.userHasPermission` — `PermissionResource.kt`
- `PermissionAvailableRequest.getResourceAsClass()` and the nested
  `PermissionContext.getResourceAsClass()` — the reflective sink
- Route guard: `ValtimoAuthorizationHttpSecurityConfigurer` (`POST /api/v1/permissions` →
  `.authenticated()`)

The `resource` field is a plain `String` with no constraint annotations, so the `@Valid` on the
request body enforces nothing against it.

## Affected versions

**All currently maintained release lines are affected.** The sink and the `.authenticated()`
route guard were confirmed present on:

- the **13.x** line (verified on `next-minor`, and reported as present on 13.40.0)
- the **12.x** line (verified on `rc/12.11.1`)
- the **14.x** line (verified on `next-major`)

This is broader than the range originally reported (`<= 13.40.0`).

## Severity

**Medium** — CVSS 3.1 base score **5.4**
`CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:N/A:L`

`PR:L` because authentication is required but no particular role is; `C:L` for the enumeration
disclosure; `A:L` because forced loading of heavyweight classes has an availability cost. Not
scored higher because no constructor is invoked, so arbitrary code execution is not directly
reachable through this path.

## Patch

Resolution restricts reflective resolution to an allowlist of registered authorization resource
types derived from `PbacRegistryService`, so `Class.forName` becomes unreachable for any
externally supplied name that is not already a known authorization resource. The rejection path
does not echo the submitted value and never reaches the class loader, which closes the
enumeration oracle as well.

The endpoint is deliberately **not** locked to `ADMIN`: the frontend calls it for ordinary users
to decide which UI affordances to render, so requiring `ADMIN` would break the application for
non-admin users and would leave the unsafe sink in place for admins.

Verified on a running instance: all 22 resource types reported by
`GET /api/management/v1/pbac/registry` still resolve, while `java.lang.System`,
`java.lang.Runtime`, `java.lang.ProcessBuilder` and non-existent names all return HTTP 200 with
`available: false` and an identical response shape. Unknown resource types are logged at DEBUG
rather than ERROR, so an authenticated user cannot flood the error log.

## Workaround

None that preserves functionality. Restricting `POST /api/v1/permissions` to `ADMIN` at a reverse
proxy prevents exploitation but breaks permission-driven UI rendering for non-admin users.

## Credit

Reported by an external security researcher through the channel listed in `SECURITY.md`.

## References

- https://github.com/valtimo-platform/valtimo/security/advisories/GHSA-9p7h-4696-wrgg

Page: https://cve.now/GHSA-9P7H-4696-WRGG

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
