Skip to content

fix(ci): Security hardening - #723

Merged
david-ruiz-cko merged 1 commit into
masterfrom
fix/INT-1911-security-hardening
Dec 2, 2026
Merged

david-ruiz-cko merged 1 commit into
masterfrom
fix/INT-1911-security-hardening

Conversation

@david-ruiz-cko

Copy link
Copy Markdown
Contributor

Summary

Security hardening of the build tooling: the CI Gradle script and Gradle always use the same
Gradle user home, the Gradle wrapper files are regenerated by Gradle 8.14.8 and pinned, and a
distribution reused from an earlier run is checked against a committed checksum. The published
library does not change.

Changes

  • .github/scripts/gradle.sh: resolves the Gradle user home once (GRADLE_USER_HOME, else
    $HOME/.gradle, made absolute), exports it and passes it with --gradle-user-home; refuses to
    run when neither variable is set. Accepts the two settings the current wrapper task writes
    (networkTimeout, validateDistributionUrl=true). Checks the wrapper jar, both start scripts
    and an unpacked distribution the wrapper would run against
    gradle/wrapper/gradle-distribution.sha256, and the layout of a reused distribution folder,
    instead of hashing the zip next to it. Runs Gradle with --no-daemon and removes the Gradle user
    home's native folder before running (only when it holds nothing but Gradle's own folders).
    Input validation of the Gradle user home path, its folders and settings, and the JVM option
    variables.
  • .github/scripts/gradle-distribution.sh (new): pin writes the checksum file from the official
    distribution after checking its sha256 against distributionSha256Sum and checking that the
    distribution's own wrapper task generates exactly the committed wrapper files; hash and sum
    compute the checksums gradle.sh compares.
  • .github/scripts/gradle-sh-test.sh (new): tests for gradle.sh with a stand-in Java, offline
    (permission cases are skipped when run as root); GRADLE_SH_TEST_REAL=1 adds runs of the real
    wrapper in a fresh Gradle home, then in the same home again, and checks that pin reproduces the
    committed checksum file and refuses a start script the release does not generate.
  • gradle/wrapper/gradle-distribution.sha256 (new): checksums of the unpacked Gradle 8.14.8
    distribution, the wrapper jar, gradlew and gradlew.bat.
  • gradlew, gradlew.bat, gradle/wrapper/gradle-wrapper.jar, gradle/wrapper/gradle-wrapper.properties:
    regenerated with ./gradlew wrapper --gradle-version 8.14.8 --distribution-type all --gradle-distribution-sha256-sum 34b008b7b744e4d12468e97ba03c572d0cd786fd0334e61e0171ea3d1a566b73
    (run twice, so the second run is Gradle 8.14.8 writing its own files); same distribution and
    sha256 as before.

Design notes: The Gradle user home is passed to the wrapper as an option so the script and Gradle
always use the same folder, and it is also exported so every process the build starts sees the
same value. The path must be absolute after resolution, without . or .. segments and in
printable ASCII, so the folder the script reads is the folder the JVM opens; an account whose home
path is not ASCII sets GRADLE_USER_HOME. Folders the script cannot read are refused rather than
skipped, and a backslash anywhere in the Gradle user home's gradle.properties is refused, so every
key is read as written (a value that needs a backslash goes in the project or the environment).
JVM option variables are compared as the JVM reads them.

The current wrapper deletes the distribution zip after unpacking, so a reused distribution is
checked against a committed checksum of the content of every file and directory of the unpacked
distribution; it works offline and is reviewed with the properties file. Only a distribution the
wrapper would run (its marker file present) is hashed: without the marker, the wrapper unpacks the
zip again after checking distributionSha256Sum, and it checks the zip itself whenever it uses it,
so the script no longer hashes the zip. The wrapper jar and start scripts are pinned in the same
file, so a change to any of them needs a new pin, and pin only writes one when the pinned
release generates exactly the committed files; the start scripts are pinned although gradle.sh
starts the jar directly, because they are what maintainers run. The check costs a few seconds per
run on a reused Gradle home (22,450 files); a fresh Gradle home, as in every CI job, has nothing to
check, and the wrapper verifies the download.

Every run starts a new Gradle process and Gradle unpacks its native libraries again, because a
running daemon and that folder outlive the run that created them; CI jobs start fresh, so they only
pay the JVM start. On a Gradle user home shared with other projects or an IDE, Gradle processes
starting at the same moment unpack their native libraries again; CI homes are not shared.
--no-daemon stays accepted as an argument for existing callers.

A wrapper update, including Dependabot's gradle-wrapper pull requests, must also run
bash .github/scripts/gradle-distribution.sh pin; until then gradle.sh refuses to run, which
is intended. gradlew.bat now has CRLF line endings, as Gradle generates it. The new test runs
locally; it is not added to a workflow, since workflows change here only when CI is broken. Gradle
stays on 8.14.8 (the workflows use JDK 11).

API Reference

None.

Breaking changes

None. The published library does not change. gradle.sh now refuses to run when neither
GRADLE_USER_HOME nor HOME is set (it failed before too, with a shell error), when the
checksum file does not match the wrapper settings or the wrapper files, when a reused
distribution folder holds anything the wrapper does not create there, and on a Gradle user home
path, folder or setting it cannot check (see Design notes). It no longer starts or reuses a
Gradle daemon, and it removes $GRADLE_USER_HOME/native (Gradle recreates it), refusing instead
when that folder holds anything Gradle does not create.

Tests

  • Existing tests pass (.github/scripts/gradle.sh build, fresh Gradle home, then again in the same home)
  • Serialization tests cover every new or changed property: not applicable, no model changed
  • README updated if documented usage changed: not needed, the documented build commands are unchanged
  • bash .github/scripts/gradle-sh-test.sh (bash 3.2 and 5.3, as a user and as root) and GRADLE_SH_TEST_REAL=1 bash .github/scripts/gradle-sh-test.sh
  • Release files staged with publishMavenPublicationToStagingRepository and compared with a build from master

Related

None.

@david-ruiz-cko
david-ruiz-cko requested a review from a team December 1, 2026 15:40
@agent-wall-e

agent-wall-e Bot commented Dec 1, 2026

Copy link
Copy Markdown

🟡 Risk Classification: MINOR

Approval route: AI Review + Human Approval
Rollback controls: Staged rollout + rollback

Classification reasons

  • exceeds_bounded_scope:1086>250

Operational gates

  • ✅ jira_ticket (INT-1911)
  • ✅ independent_review

Files analysed: 8


wall-e 2026.06.19-02 · policy 6b4ce2b3b45a…

@agent-wall-e

agent-wall-e Bot commented Dec 1, 2026

Copy link
Copy Markdown
🔬 Debug — why this classification?

Each reason code emitted by the classifier, its source clause in the AI in SDLC Control Framework, and what it means.

Reason code Kind Clause Meaning
exceeds_bounded_scope — 1086>250 classifying §2.1 M8 More than 250 non-test, non-doc, non-lockfile lines changed.

Kinds:

  • classifying — this rule contributed to the chosen tier.
  • informational — context only; did not by itself decide the tier.

See issue #3 for the proposal to formalise this map as Appendix A of the standards doc.

wall-e 2026.06.19-02 · debug

@sonarqubecloud

sonarqubecloud Bot commented Dec 1, 2026

Copy link
Copy Markdown

@david-ruiz-cko
david-ruiz-cko merged commit add6348 into master Dec 2, 2026
6 checks passed
@david-ruiz-cko
david-ruiz-cko deleted the fix/INT-1911-security-hardening branch December 2, 2026 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants