# Verification Report

## Fix Summary

The patch applies the reviewed PR #7703 AutoType hardening to fastjson2 2.0.62. It rejects attacker-controlled type names containing URL-special `:` or `!` before class resolution, repeats that guard in the generic class-loading utility, verifies hash-based allowlist matches against the actual normalized textual prefix, and applies dangerous `ClassLoader`/SQL data-source restrictions consistently. This prevents the confirmed `jar:http:...!...` value from reaching Spring Boot's JDK 8 `LaunchedURLClassLoader` while preserving ordinary Java class loading and configured allowlist behavior.

## Changes Made

- `core/src/main/java/com/alibaba/fastjson2/reader/ObjectReaderProvider.java`
  - Adds a normalized textual accept-name set alongside prefix hashes.
  - Rejects `:` and `!` before AutoType allowlist traversal or class loading.
  - Requires an exact normalized textual prefix after a hash match.
  - Applies `ClassLoader` and SQL `DataSource`/`RowSet` restrictions in the non-explicit-AutoType allowlist branch.
- `core/src/main/java/com/alibaba/fastjson2/filter/ContextAutoTypeBeforeHandler.java`
  - Stores normalized accepted names, rejects URL-special forms, and textually confirms hash matches.
- `core/src/main/java/com/alibaba/fastjson2/util/TypeUtils.java`
  - Adds defense-in-depth rejection before any attacker-influenced name reaches a class loader.
- `core/src/test/java/com/alibaba/fastjson2/autoType/AutoTypeValidationTest.java`
  - Adds 14 focused tests for `:`/`!` rejection, valid class loading, allowlist behavior, and parser filters.

Deliverables:

- Patch: `bundle/coding/proposed_fix.diff` (SHA-256 `8b56b113e0fbc25c6b03526979b8e049d5181840f5a5d6d59eee47fac9bf3e2f`)
- Verifier: `bundle/coding/verify_fix.sh`

## Verification Steps

1. `verify_fix.sh` acquires an isolated checkout at the exact vulnerable release commit `7ddfd76e03bd263f4dd3a33dd403bd2387d2c801` and resets it before every run.
2. It runs `git apply --check bundle/coding/proposed_fix.diff`, applies the deliverable with index verification, and requires exactly four expected changed paths.
3. It hashes the three patched production files and requires byte-for-byte equality with reviewed PR #7703 commit `5552cad1b132a88e7592f487988649835318a8d3`. Canonical run 11 recorded:
   - `22783662...` — `ContextAutoTypeBeforeHandler.java`
   - `9cd3d3e4...` — `ObjectReaderProvider.java`
   - `0ca667fa...` — `TypeUtils.java`
4. In pinned `maven:3.9.9-eclipse-temurin-8`, it packages the patched core and compiles/runs only the new focused JUnit class using pinned JUnit Platform 1.13.4.
5. It builds a fresh marker-only artifact server and JDK 8/Spring Boot 2.7.18 target on an internal Docker network.
6. As a live positive control, released 2.0.62 receives `jar:http:..artifact:8000.probe!.POC` through explicit text AutoType. The verifier requires a remote artifact fetch, static-initializer evidence, and a per-run marker nonce.
7. The freshly patched JAR receives the identical type name through:
   - implicit `@JSONType(seeAlso)` polymorphic text parsing (the parent entry point),
   - explicit text AutoType,
   - explicit JSONB AutoType.
   Each case must throw `JSONException`, make zero fetches, and create no marker.
8. The complete verifier was executed twice successfully (runs 10 and 11) to establish idempotency.

Command:

```bash
bundle/coding/verify_fix.sh
```

Canonical output from both successful runs:

```text
RESULT=FIX_VERIFIED
PATCH_APPLIES_CLEANLY=true
PATCHED_PRODUCTION_BLOBS_MATCH_REFERENCE=true
FOCUSED_UNIT_TESTS=PASS
VULNERABLE_POSITIVE_FETCH_DELTA=1
VULNERABLE_POSITIVE_MARKER=true
PATCHED_TEXT_POLYMORPHIC_FETCH_DELTA=0
PATCHED_TEXT_POLYMORPHIC_MARKER=false
PATCHED_TEXT_EXPLICIT_FETCH_DELTA=0
PATCHED_TEXT_EXPLICIT_MARKER=false
PATCHED_JSONB_EXPLICIT_FETCH_DELTA=0
PATCHED_JSONB_EXPLICIT_MARKER=false
```

## Test Results

- **Patch applicability:** PASS against exact release commit `7ddfd76e...`; a final independent `git apply --check` also passed after resetting the checkout.
- **Production build/checkstyle:** PASS via `mvn -B -ntp -DskipTests package` on the patched source.
- **Focused unit regressions:** PASS — 14 found, 14 started, 14 successful, 0 failed, 0 aborted, 0 skipped (`bundle/logs/coding/run11/unit_tests.log`).
- **Vulnerable exploit control:** PASS — one controlled remote fetch and marker `FJ2_CODING_REMOTE_BYTECODE_32182-11` (`run11/vulnerable_text_explicit.summary`).
- **Patched parent polymorphic path:** PASS — zero fetches, no marker, fail-closed `JSONException`.
- **Patched explicit text path:** PASS — zero fetches, no marker, fail-closed `JSONException`.
- **Patched JSONB path:** PASS — zero fetches, no marker, fail-closed `JSONException`.
- **Idempotency:** PASS — complete fresh runtime validation succeeded in both `bundle/logs/coding/run10/` and `run11/`.

Canonical current-run evidence is under `bundle/logs/coding/run11/`, with the concise verdict also copied to `bundle/logs/coding/proof_summary.log`.

## Remaining Concerns

- The fix fully blocks the demonstrated Spring Boot/JDK 8 remote-JAR name shape but is not a complete positive grammar validator for all Java binary names.
- `ObjectReaderSeeAlso` still internally enables `SupportAutoType`; a long-term design correction should make unknown declared subtypes fail closed unless the application explicitly opts into global AutoType resolution.
- Direct context-loader reconciliation/cache paths should eventually consume a centralized validated-name abstraction rather than relying on prior validation state.
- Startup `-Dfastjson2.parser.safeMode=true` and outbound egress restrictions remain useful defense in depth until consumers deploy an official release containing this fix.
- Additional integration coverage should include modern JDKs, newer Spring Boot loaders, custom handlers/allowlists, and cache-hit paths.
