Repository navigation
Refuse settings files in a submission that would run student code before Ares starts - #466
MarkusPaulsen wants to merge 10 commits into
Conversation
A file a student puts into src/main/resources reaches the class path of the test run. archunit.properties can name a class resolver, and a file below META-INF/services can name an ArchUnit extension; ArchUnit then creates the student's class during Ares's own import or rule check, before anything is supervised. Both were reproduced end to end. Before Ares imports anything, Postcompile now looks into the compiled outputs (target/classes, build/classes/java/main, build/resources/main) and refuses the run if one holds a service file or archunit.properties, junit-platform.properties or a Logback file at its top. The folder Ares itself was loaded from is skipped, since that is Ares's own build. A JUnit listener named in a service file runs before any Ares code, so only the build boundary can stop that one; this check still fails the run.
A student could place files in src/main/resources that JUnit, ArchUnit or Logback read from the test class path before Ares is active. A service file under META-INF/services naming a TestExecutionListener made JUnit run a student class before any Ares code; an ArchUnitExtension service file or a classResolver entry in archunit.properties made ArchUnit instantiate a student class at Ares's first rule check or import; archunit_ignore_patterns.txt can hide ArchUnit findings; junit-platform.properties and the Logback configuration files steer those frameworks the same way. The reserved-package build boundary only looked at class files under reserved package prefixes, and the Gradle task did not even scan the processed resources. Boundary version 3 rejects every file under META-INF/services/ and the files archunit.properties, archunit_ignore_patterns.txt, junit-platform.properties, logback.xml, logback-test.xml, logback.groovy, logback.scmo and logback-test.scmo at the root of the student's output, ignoring case. The Gradle task now scans the whole main output, resources included. The Maven filesets also switch off Ant's default excludes, which silently skipped a reserved package folder named CVS or SCCS (for example org/junit/CVS). Instructor configuration of this kind belongs in src/test/resources, which the check does not scan. The task name, execution id, failure message and version constant move to 3, and every verbatim copy in the examples and the documentation follows.
…jects The build boundary now also rejects the ArchUnit ignore file, the Logback .scmo files, the JaCoCo agent settings and Mockito plugin files. The run time check refuses the same files, so an exercise with an older snippet is held to the same list.
…ing case Mockito instantiates the class named in a file under mockito-extensions/ at the first mock, and the JaCoCo agent reads a root jacoco-agent.properties at startup, both from the test class path and possibly before Ares is active. Boundary version 3 now rejects both in the student's output, like the other framework files. The reserved package prefixes were still compared with their case. On a case-insensitive file system the class loader finds ORG/junit/Evil.class as org/junit/Evil.class, so such a file, for example copied in as a resource, passed the check. Both snippets now compare package prefixes ignoring case as well; ordinary student packages such as org/example still pass. The examples workflow now also plants a JUnit service file in a copy of each example and requires the boundary's failure, as it already does for impostor classes. Version 3 is unreleased, so the version stays at 3.
The check ran when Ares built its first test case. By then Logback had already read its configuration through the first Ares logger, and JUnit had read junit-platform.properties, so a file the check exists for could take effect, and remove itself, before it was looked for. The Ares jar now registers a launcher session listener that runs the check before any test is found and before Ares logs anything. The class comment states what it still cannot stop: a JUnit listener or the JaCoCo agent read their files earlier, which only the build boundary prevents. The troubleshooting page explains the refusal.
A module-info.java in the submission makes Surefire run its module from the module path, and its provides lines then make the JDK create a class the student wrote: Logback asking for an XML parser created a student SAXParserFactory and DocumentBuilderFactory before Ares checked anything, and the class read and wrote out secret.txt. The run start check now also refuses a module-info.class at the top of a compiled output or below its versioned folders. The refusal no longer names src/main/resources, since a descriptor comes from the sources.
A student module-info.java with provides clauses, for example for SAXParserFactory, DocumentBuilderFactory or FileSystemProvider, made Surefire put the student code on the module path. ServiceLoader then ran the student's provider class before Ares was active, which could read and write files unsupervised. Boundary version 3 now rejects a module-info.class in any folder of the student's output, the root and META-INF/versions/*/ included, ignoring case, in both the Maven and the Gradle snippet and all copies. A resource merely named like it, such as module-info.txt, still passes. The examples workflow also plants an empty module descriptor in a copy of each example and requires the boundary's failure. Version 3 is unreleased, so the version stays at 3.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
| Check name | Status | Explanation |
|---|---|---|
| Sandbox Fail-Closed Behaviour | Summary: The enforcement changes in PR #466 keep fail-closed behaviour for unknown, unreadable and malformed inputs. The check passes. Scope of evidence. The PR adds nine commits (0ba8c40 to … |
|
| Github Workflow Least Privilege | The PR changes one workflow file: .github/workflows/examples.yml. I compared it with main (git diff main...HEAD -- .github/workflows/examples.yml). Least privilege: - The workflow sets top-level… |
Full details: Sandbox Fail-Closed Behaviour
-
Explanation
Summary: The enforcement changes in PR
#466keep fail-closed behaviour for unknown, unreadable and malformed inputs. The check passes. Scope of evidence. The PR adds nine commits (0ba8c40 to 1337ff1) on top of 75b2bfb. The enforcement code it changes is: -FrameworkConfigurationGuard.java(new): a runtime scan of the compiled output folders. -FrameworkConfigurationListener.java(new): a JUnitLauncherSessionListenerthat calls the guard. -WalaPathClassification.java: changed only in Javadoc and in theRESERVED_PACKAGE_BUILD_BOUNDARY_VERSIONconstant (2 to 3). No classification logic changed. - The Gradle and Maven build-boundary snippets (version 3). Fail-closed evidence in the runtime guard: -firstServiceFileInreturns the service folder itself ifFiles.walkthrowsIOExceptionorUncheckedIOException. Any service folder that cannot be read therefore refuses the run. -firstModuleDescriptorIndoes the same whenFiles.listonMETA-INF/versionsfails. - Existence checks useLinkOption.NOFOLLOW_LINKS, so dangling symbolic links still count as present. -aresOrigin()returnsnullwhen the code source is missing, is not afile:URL, or cannot be converted. The guard then skips nothing, becauseabsolute.equals(null)is false. -requireNone()throwsSecurityExceptionwith a localised message. The keyssecurity.framework.configurationexist in bothmessages.propertiesandmessages_de.properties. - Any unexpected runtime exception in the listener aborts the JUnit session, which is also fail-closed. Fail-closed evidence in the build boundaries: - Maven: the<fail>condition trips when either resource count is non-zero. Thecasesensitive="false"anddefaultexcludes="no"settings widen the match. - Gradle:doLastcollects every match and throwsGradleExceptionwhen the list is non-empty. Names are compared in upper case and then lower case. - Both boundaries run atprocess-resourcesor beforecompile, so they cannot run after the student code has run. Residual observations (not failures under this check): 1.requireNone()skips an output folder equal to the folder Ares was loaded from. This is a deliberate exemption for Ares's own build. In an exercise, Ares is loaded from a jar, so the exemption does not apply to student output. 2. The guard and the Gradle boundary ignore an output path that exists but is not a directory. Neither a JVM classpath nor Gradle would treat such a path as student classes. 3. The Gradle boundary skips dangling symbolic links, becausecandidate.isFile()is false for them. Gradle resource processing normally copies content rather than links, so the practical risk is low. 4.FrameworkConfigurationGuardTestcovers the positive and negative file-name cases. It does not cover theIOExceptionbranches directly. This is a test gap, not a behaviour gap; the code paths shown above refuse the run. I did not build or run the tests, because the sandbox does not support the build toolchain. The verdict rests on reading the code and the diff.
Full details: Github Workflow Least Privilege
-
Explanation
The PR changes one workflow file:
.github/workflows/examples.yml. I compared it withmain(git diff main...HEAD -- .github/workflows/examples.yml). Least privilege: - The workflow sets top-levelpermissions: {}. - Theexamplesjob setspermissions: contents: read. - The diff does not add or widen any permission. Secrets and untrusted code: - The trigger ispull_request, notpull_request_target. A fork PR therefore runs without repository secrets and with a read-only token. - The checkout step usesactions/checkoutwithpersist-credentials: false. - The workflow does not referencesecrets.anywhere. - The added steps are shell functions. They copy the example, plant a resource or module file, and run the build. They use only local shell variables and the matrixtoolvalue. They do not interpolate${{ github.event.* }}intorun:blocks. Unsafepull_request_targetpatterns: - No workflow in this repository usespull_request_targetin a way that this PR changes. The only occurrence is inpullrequest-labeler.yml, which this PR does not modify. - The PR does not add apull_request_targettrigger or a checkout of PR head code under that trigger. The other files in the diff (.github/ISSUE_TEMPLATE/bug-report.ymland.github/scripts/CheckReleaseTemplate.java) are not workflow files. The check does not assess them. No failure condition applies.
Full details: Trusted Boundary Preservation
-
Explanation
Summary: The settings-file refusal keeps trusted infrastructure, test fixtures and student code apart. The change to essential JDK packages does not. It widens what supervised code may import, which weakens the separation the check requires. Preserved separation (checked): -
FrameworkConfigurationGuardandFrameworkConfigurationListenerscan only the default student output folders (target/classes,build/classes/java/main,build/resources/main). They skip Ares's own origin folder. - The Ares listener is registered throughsrc/main/resources/META-INF/services/org.junit.platform.launcher.LauncherSessionListener. This is trusted Ares infrastructure in the Ares jar. - The Gradle boundary (examples/ares-exercise-gradle/gradle/AresReservedPackages.gradle) scanssourceSets.main.output. The Maven boundary (examples/ares-exercise-maven/pom.xml) scans${project.build.outputDirectory}. Neither scanssrc/test/resources, so instructor fixtures stay outside the check. - The two boundary snippets list the same reserved patterns and the same settings files. Separation weakened (diff evidence): -src/main/resources/.../essentialFiles/java/EssentialPackages.yamlnow states that an essential entry covers the packages below it. Previously, JDK namespace entries were exact matches. The comment now saysjava.langincludesjava.lang.reflect,java.lang.invoke,java.lang.instrumentandjava.lang.management. -JavaCreator.validatedEssentialPackagenow callsnew PackagePermission(packageName). The previous code passedPackagePermission.isInJdkNamespace(packageName)as a second argument. That flag no longer exists on the record. The JDK-namespace exact-match rule has been removed from essential grants. - As a result, supervised code can import JDK sub-packages that it could not import before, and that the policy did not grant. These packages sit in the trusted platform namespace that Ares treats as special. - The PR description does not disclose this change. It concerns import scope, not settings files. Mitigation (not verified): The comment inEssentialPackages.yamlsays the method rules still refuse use of these packages. I did not verify those rules forjava.lang.instrumentandjava.lang.management. The change is therefore a permission widening, not a confirmed bypass. Verdict: The check requires separation between trusted infrastructure and supervised code. This PR removes an exact-match guard for JDK packages from the essential grant. Because the change is in the diff and not disclosed, the check fails.Resolution
- Restore exact-match handling for JDK-namespace essential packages. Essential entries in
java.*,javax.*,jdk.*,sun.*andcom.sun.*must not cover sub-packages. Re-add the JDK exact-match flag toPackagePermissionor an equivalent check inJavaCreator.validatedEssentialPackage. Revert theEssentialPackages.yamlcomment to match. 2. If the wider grant is intended, state it in the PR description. Add the affected packages to the reviewed boundary list, and confirm with tests that the method rules refusejava.lang.instrument,java.lang.management,java.lang.reflectandjava.lang.invokefor supervised code. 3. Re-run the essential-package and import-permission tests after the change.
- Restore exact-match handling for JDK-namespace essential packages. Essential entries in
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Claudia-Anthropica
left a comment
There was a problem hiding this comment.
@MarkusPaulsen I found one security gap: Maven can execute a student-supplied annotation processor before the new resource check runs. The Ubuntu Gradle example check failed, but the captured evidence only reports exit code 1, so I couldn't attribute that failure. Several other checks are still running.
Maven copies src/main/resources into target/classes during process-resources, and javac and ajc look for annotation processors in that folder. A service file there naming a processor class the student supplied therefore ran student code inside the compiler, before the boundary looked at anything at process-classes. The Maven snippet now holds its check once, on the plugin, and runs it in two executions: verify-ares-reserved-resources-v3 at process-resources, after the resources are copied and before the compiler starts, and verify-ares-reserved-packages-v3 at process-classes as before. Every copy, the example and the pages follow. Gradle is not affected: compileJava does not put the processed resources on its class path, and Gradle takes processors only from the annotationProcessor configuration. The boundary test checks both executions and their phases, and the Examples workflow plants a processor service file, which under Maven fails the compiler unless the earlier check rejects it first.
Claudia-Anthropica
left a comment
There was a problem hiding this comment.
@MarkusPaulsen The pre-compilation check fixes the annotation-processor gap. I found one regression: clean Maven builds without main resources now fail before compilation. Both Run the maven exercise on windows-2025 and Run the maven exercise on ubuntu-26.04 failed, but their captured annotations only report exit code 1, so I can't confirm the failing step. Several other checks are still running.
At process-resources a project without src/main/resources has no target/classes yet, and an Ant fileset on a missing folder fails the build, so the unchanged example stopped before compiling. The check now creates the output folder first, in every copy of the snippet, and the boundary test requires that step.
Claudia-Anthropica
left a comment
There was a problem hiding this comment.
@MarkusPaulsen The pre-compilation check and output-directory creation fix both earlier Maven issues, and the example and documentation copies match the shipped snippets. I found no remaining issues in the full diff; this looks good to me. Build, documentation, CodeQL and example checks are still running.
Summary
A file a student puts into
src/main/resourcesreaches the test run, and some files there make JUnit, ArchUnit, Logback, Mockito or the JDK create a class the student wrote before Ares supervises anything. The build boundary of the examples and setup pages, now version 3, rejects these files, and Ares refuses the test run when it finds one. Ordinary resources are unaffected.Linked issues
Split from #461
1. Problem
Student code could run before the policy applied, in all four modes and with Maven and Gradle alike. The faulty part is how Ares is plugged into the build (the reserved-package build boundary, which keeps student files out of places Ares reserves for itself) and how it hooks into JUnit.
Test libraries read settings files from the class path, and the compiled
src/main/resourcesof a submission is on it: a file belowMETA-INF/servicesormockito-extensions, a top-levelarchunit.properties,archunit_ignore_patterns.txt,junit-platform.properties, Logback file orjacoco-agent.properties, or theprovideslines of amodule-info.class. Several of these name a class to create, and that class ran before any Ares check, so the policy did not apply to it. Under Maven, an annotation processor named there even ran inside the compiler, before any check. The build boundary looked only at class files in reserved packages, and only after compiling.2. Improvement from the user's perspective
A settings file in a submission no longer runs the student's code before the policy applies. The build stops before the first test and, with Gradle, names the file; if an exercise still carries the old boundary, Ares itself refuses the run with a message naming the file and the folder it was found in. Instructors who need such a file keep it in
src/test/resources, which the check leaves alone. Ordinary resources such asdata/words.txtstill pass.3. Improvement from the maintainer's perspective
FrameworkConfigurationGuardTestcovers every refused file, the module descriptor in a versioned folder, a file in place of the service folder, ordinary resources and Ares's own build.ReservedPackageBuildBoundaryTestchecks that the Maven and Gradle fixtures reject exactly the same files, ignore case and name the same boundary version, and the Examples workflow now plants a service file and a module descriptor in both examples. Every verbatim copy of the snippet in the examples and the documentation moves to version 3 together.4. Testing manual
Prerequisites
mainand this branch once each and keep both, from the repository root:git switch mainthenmvn -q install -DskipTests -Pwithout-quality-gates, then copy~/.m2/repository/de/tum/cit/ase/ares/2.2.2to a folderares-mainnext to the clone.git switch fix/enforcement/ares-222-framework-settings-filesthen the samemvncommand.~/.m2now holds the branch build as 2.2.2.git switch mainand copyares-mainback over~/.m2/repository/de/tum/cit/ase/ares/2.2.2; to run it on the branch,git switchback and run themvn installcommand again.examples/ares-exercise-mavenandexamples/ares-exercise-gradleyou are the instructor: the test class andsrc/test/resources/SecurityPolicy.yamlare yours,Penguin.javaandsrc/main/resourcesare what a student hands in. Rungit checkout -- examplesandgit clean -fdx examplesafter each step.mavenLocal()as the first line insiderepositories { }inexamples/ares-exercise-gradle/build.gradle.Steps
examples/ares-exercise-mavencreatenotes.txtwith one line; the policy has no entry for it. Addsrc/main/java/org/example/Observer.java: a public class implementingorg.junit.platform.launcher.TestExecutionListenerwhose static initialiser prints"SEEN " + java.nio.file.Files.readString(java.nio.file.Path.of("notes.txt")), wrapped in atry/catch (Exception e)that prints the exception instead. Addsrc/main/resources/META-INF/services/org.junit.platform.launcher.TestExecutionListenercontaining the single lineorg.example.Observer. Runmvn teston main, then on the branch.examples/ares-exercise-gradleaddsrc/main/resources/archunit.propertieswith the lineresolveMissingDependenciesFromClassPath=true. Run./gradlew test(gradlew.bat teston Windows) on main, then on the branch.~/.m2, but replace the boundary snippet by the one of main, whose boundary is version 2:git show main:examples/ares-exercise-gradle/gradle/AresReservedPackages.gradle > examples/ares-exercise-gradle/gradle/AresReservedPackages.gradle. AddmavenLocal()again and thearchunit.propertiesof step 2, and run./gradlew test.src/main/java/module-info.javacontainingmodule example { }and run./gradlew test.examples/ares-exercise-mavenaddsrc/main/resources/META-INF/services/javax.annotation.processing.Processorcontaining the single lineorg.example.Penguin. Penguin is no processor, so whether the compiler reads the file shows in the output. Runmvn teston main, then on the branch.Expected result
SEENand the line ofnotes.txtappear in the build output before the first test: the class ran before Ares was active, so its read of a file the policy does not list was not refused. On the branch the build stops before any test withAres reserved-package validation 3 rejected student output. No bypass flag is supported.and noSEENline appears.Ares reserved-package validation 3 rejected student output: [archunit.properties]. No bypass flag is supported.Ares Security Error (Reason: Student-Code; Stage: Creation): The compiled submission contains archunit.properties infollowed by thebuild/resources/mainfolder of the example. This is the check Ares itself runs when JUnit opens the test run, for exercises that still carry an older snippet. A JUnit listener such as the one of step 1 is read even earlier, so only the version 3 snippet stops that one.Ares reserved-package validation 3 rejected student output: [module-info.class]. No bypass flag is supported.compiler:compilewithBad service configuration file, or exception thrown while constructing Processor object: javac read the student's file and tried to run what it names, before any check. On the branch the build output showsantrun:3.2.0:run (verify-ares-reserved-resources-v3)right afterresources:resourcesand stops there with the version 3 diagnostic; the compiler never starts. On an unchanged example bothverify-ares-reserved-resources-v3andverify-ares-reserved-packages-v3run and the tests pass.Negative case (what must still be rejected)
rejectsTheForbiddenFilestill shows thatPenguincannot read a file the policy does not list.archunit.propertiesbysrc/main/resources/data/words.txtandsrc/main/resources/META-INF/notes.txt. The build succeeds and the tests pass: only the named settings files, the two folders and a module descriptor are refused.archunit.propertiesintosrc/test/resourcesinstead. The tests run: instructor files are not checked.ArchUnit.Properties. It is still rejected, since the boundary ignores case.mvn test -Dtest='FrameworkConfigurationGuardTest,ReservedPackageBuildBoundaryTest,ReservedPackageSnippetCopiesTest'checks every refused file and every snippet copy. The Examples workflow of this pull request plants a service file and a module descriptor in both examples and requires the version 3 diagnostic; read its step "Confirm the reserved-package boundary rejects impostors".Precompile exercises get the run start check once the Precompile change split from #461 is merged as well, since that pull request adds the guard Precompile runs before its first test. The build boundary of this pull request already covers them.
Modes exercised
The steps use the examples as shipped, that is ArchUnit with AspectJ; the branch side of the Gradle steps and the negative cases 2 to 4 were run that way. Neither the build boundary nor the run start check reads the mode, so they behave the same in all four. The other three were exercised by running integration tests of this repository in all four modes, since every one of them now passes the run start check first.
5. Test case coverage regarding this PR
FrameworkConfigurationGuardFrameworkConfigurationListenerWalaPathClassificationBreaking changes and migration
src/main/resourcesholds a file belowMETA-INF/servicesormockito-extensions, a top-levelarchunit.properties,archunit_ignore_patterns.txt,junit-platform.properties, Logback file orjacoco-agent.properties, or amodule-info.class, is now refused: by the build boundary and again when the tests start. Keep such files insrc/test/resources; an exercise that is a Java module cannot be graded.Checklist
documentation/,README.md, Javadoc) was updated where the change is user-facing.Review progress