On Wed, 2 Dec 2026 06:53:53 GMT, xiaotaonan <[email protected]> wrote:

>> The Classfile API verifier (`VerifierImpl`) currently skips methods marked 
>> with `ACC_BRIDGE` during verification. This is inconsistent with HotSpot's 
>> verifier, which only skips overpass methods (VM-generated) and still 
>> verifies ordinary bridge methods.
>> 
>> A maliciously crafted class file could therefore mark a method with 
>> `ACC_BRIDGE` to bypass verification entirely.
>> 
>> This fix aligns the Classfile API verifier with HotSpot by replacing the 
>> `isBridge()` check with an equivalent overpass check.
>> 
>> Testing:
>> - Added a regression test that constructs a class file with an invalid 
>> method body marked `ACC_BRIDGE`, and verifies that the Classfile API 
>> verifier now rejects it.
>> - Ran the existing `java/lang/classfile` and `jdk/internal/classfile` tests.
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> xiaotaonan has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   fix: Modify according to the review comments.

The fix should rather completely remove the bridge methods exception from 
verification.

src/java.base/share/classes/jdk/internal/classfile/impl/verifier/VerifierImpl.java
 line 265:

> 263:         var errors = new ArrayList<VerifyError>();
> 264:         for (VerificationWrapper.MethodWrapper m : _klass.methods()) {
> 265:             if (m.isNative() || m.isAbstract() || m.isOverpass()) {

Class-File API verifier incorrectly skips bridge method bodies at the point 
where HotSpot’s verifier skips VM-generated overpass methods. Overpass flag is 
not present in physical class files and overpass methods never appear at this 
point.  

Suggestion:

            if (m.isNative() || m.isAbstract()) {

-------------

Changes requested by asotona (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/34176#pullrequestreview-6150185004
PR Review Comment: https://git.openjdk.org/jdk/pull/34176#discussion_r4769090265

Reply via email to