T08 · Insecure Dependencies
Error
- Location
- references/openrewrite-recipes.md:64
- Finding
- Unpinned OpenRewrite Recipe Dependency Permits Mutable Supply-Chain Code Execution## Vulnerability Details **File Location**: `references/openrewrite-recipes.md`, lines 64–66 **Vulnerability Type**: Unpinned third-party dependency **Risk Level**: High ### Technical Analysis The documented one-shot migration command resolves the OpenRewrite recipe artifact using the mutable `LATEST` version: ```bash ./mvnw -U org.openrewrite.maven:rewrite-maven-plugin:run \ -Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-spring:LATEST \ -Drewrite.activeRecipes=org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_5 ``` `LATEST` does not identify a stable, previously reviewed artifact. Maven consults remote repository metadata at execution time and selects whichever version is then designated as the latest release. The `-U` option further directs Maven to check remote repositories for updated metadata and artifacts. OpenRewrite recipe artifacts contain executable Java components loaded by the Rewrite plugin. Consequently, executing this command gives the newly resolved artifact the ability to run in the Maven process and intentionally modify the target repository. The effective executable dependency can therefore change after this skill package has been audited, without any corresponding change to the reviewed documentation. Although the document elsewhere recommends looking up current versions, this executable example explicitly uses `LATEST`, preventing reproducible resolution and bypassing meaningful version review or approval controls. ### Attack Path 1. An attacker compromises the upstream `rewrite-spring` publishing process, an authorized publisher account, or a repository through which Maven resolves the artifact. 2. The attacker publishes a malicious or compromised version that becomes the version represented by `LATEST`. 3. An agent follows the documented migration command. 4. Maven refreshes repository metadata because of `-U` and downloads the attacker-controlled recipe artifact. 5. ...[truncated 1552 chars]
- Remediation
- ## Remediation Suggestions 1. Replace `LATEST` with an explicit, reviewed recipe version: ```bash ./mvnw org.openrewrite.maven:rewrite-maven-plugin:PINNED_PLUGIN_VERSION:run \ -Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-spring:PINNED_REWRITE_SPRING_VERSION \ -Drewrite.activeRecipes=org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_5 ``` 2. Pin the OpenRewrite Maven plugin version as well, either in `pom.xml` or in the fully qualified command, so all executable components are deterministic. 3. Remove `-U` from routine migration commands. Use it only during an explicit, controlled dependency-update process. 4. Verify selected versions against official release records and review release notes before execution. 5. Enforce trusted Maven repositories through organization-controlled `settings.xml` mirrors. Disable unapproved repositories declared by projects or transitive build configuration. 6. Use repository-manager checksum and signature validation where available. Record resolved artifact versions and hashes in migration logs. 7. Run OpenRewrite in an isolated, least-privileged environment without production credentials, unnecessary filesystem access, or unrestricted network access. 8. Review the complete generated diff before staging or committing it. Do not automatically treat recipe-generated changes as trusted. 9. Configure automated dependency-update tooling to propose reviewed version bumps rather than selecting mutable versions at execution time.
