Repository navigation
JCU/Fix dspace-customers 1083 finding 6: keep the backend application files owned by root - #1710
Open
milanmajchrak wants to merge 6 commits into
Open
milanmajchrak wants to merge 6 commits into
milanmajchrak wants to merge 6 commits into
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
solr-reindex-statistics removes its export folder only when it created it, so the image no longer creates /dspace/solr-export. The solr-*-statistics commands take -d instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
The Dockerfile permission change causes stats-util -s and stats-util -b to fail during cleanup because deleting /dspace/temp requires write access to the protected /dspace parent.
1 open issue
What changed in this PR
Applies the root-ownership hardening from PR #1706 to this branch’s Spring Boot backend image, while retaining writable runtime data directories.
Changes:
- Keeps installed application files root-owned while DSpace runs as
dspace. - Creates and assigns ownership of data directories, including
sitemaps, and permits Discovery reindex flag creation. - Preserves read and execute access to installed scripts.
| File | Description |
|---|---|
| Dockerfile | Restricts writable paths to runtime directories and preserves script execution permissions. |
Review effort: Balanced
stats-util -s and -b delete /dspace/temp when they finish, and solr-reindex-statistics creates and deletes /dspace/solr-export. Both need write access to /dspace. With the sticky bit dspace can add and remove its own entries there, but not the root-owned ones. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DSpace only needs to create and delete reindex.flag there. With the sticky bit it can, while schema.xml and solrconfig.xml stay root-owned. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
The writable working directory still lets dspace create Spring Boot configuration files that override protected settings on startup, leaving a critical configuration-tampering path open.
1 open issue
1 resolved since last review
Review effort: Balanced
/dspace is the working folder and dspace can now add files there. The default Spring Boot locations stay, except ./ itself. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


References
dspace-customers issue 1083, finding 6. Same idea as #1706 on dtq-dev, written for the Spring Boot image of this branch. This PR also creates
/dspace/sitemaps, which is all that the open PR 1506 does.Description
The backend image now keeps the DSpace files owned by root. DSpace still runs as
dspace, which owns only the data folders.Instructions for Reviewers
List of changes in this PR:
Dockerfile:COPY --from=ant_build /dspace $dspace__P__dirdrops--chown, so/dspacestays owned by root.dspaceowns only the data foldersassetstore,ctqueues,exports,handle-server,imports,log,reports,sitemaps,temp,triplestore,uploadandvar(missing ones are created)./dspaceandsolr/search/confareroot:dspacewith the sticky bit. DSpace can add and remove its own entries there (stats-util -sremovestemp, CLI output to a relative path,database migratewritesreindex.flagso DSpace reindexes Discovery at start), but it cannot replace the others.SPRING_CONFIG_LOCATIONkeeps the Spring Boot defaults exceptfile:./, so Spring Boot does not read anapplication.propertiesfrom the working folder/dspace./dspace/bingetsa+rX, sodspacecan still run the installed scripts (the installer makes them744).Named volumes that already exist keep their owner, so deployments need no migration. What changes:
dspace stats-util -ucan no longer download spider lists intoconfig/spiders, anddspace submission-forms-migratecannot write its.migratedfiles intoconfig.Run CLI commands as
dspace, the default fordocker exec. DSpace cannot remove what root creates in the sticky folders, for example areindex.flagfrom a migration run as root.How to test:
All three
touchcommands fail withPermission denied.Also tested on a stack with PostgreSQL, Solr and named volumes, running
database migrate forcebefore the jar: once with the currentcustomer-jcuimage, once with this PR's final stage on top of the install from that image. Both start and answer on/server/api. With the PR image the Discovery reindex after the first migration still runs,stats-util -sends without an error, anapplication.propertieswritten to/dspaceis ignored after a restart, and writes toconfig,libandwebappsare refused.Codex review (gpt-6.2-sol, high), 4 rounds: 2 findings fixed. The last round flagged only the changes listed above, the root-run case, and a run as UID 1100 without the
dspacegroup, which our compose files do not do.AI Disclosure (REQUIRED)
Were AI tools used in the creation of this PR?
Claude Code wrote the change and tested it in Docker as described above.
Checklist
mainbranch of code (unless it is a backport or is fixing an issue specific to an older branch).pom.xml), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.🤖 Generated with Claude Code