Skip to content
RCE Advisory Advanced CVE-2023-25581

GHSL-2022-085: Java deserialization leading to RCE in pac4j-core - CVE-2023-25581

pac4j-core before version 4 deserialises untrusted string attributes that begin with a special prefix, allowing an attacker to supply a serialised Java object and potentially achieve remote code execution. The flaw is in the InternalAttributeHandler class, which fails to check if a string already starts with the prefix before deserialising it.

Michael Stepankin Follow

Originally disclosed on GitHub Security Lab

pac4j-core prior to version 4 is affected by a Java deserialization vulnerability. The vulnerability affects systems that store externally controlled values in attributes of the UserProfile class from pac4j-core.

artsploit, on GitHub Security Lab

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Impact

This issue may lead to Remote Code Execution (RCE) in the worst case, although a RestrictedObjectInputStream is in place that puts some restriction on what classes can be deserialised, it still allows a broad range of java packages and potentially exploitable with different gadget chains.

What the attacker needed

Attacker controls a string attribute; attribute stored in UserProfile; attribute later restored

The fix

The vulnerability was fixed in version 4.0 of pac4j-core.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

Java serialisation turns objects into a stream of bytes so they can be saved or sent over a network. If an application deserialises data from an untrusted source, an attacker can craft malicious bytes that, when turned back into an object, run harmful code. Here, a library called pac4j-core did not check that a string attribute was safe before deserialising it, so an attacker could hide a malicious serialised object inside a normal-looking string.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

More by Michael Stepankin

View all

16 more disclosed reports, best first.

More from GitHub Security Lab

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.