Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disallow student classes in trusted packages #15

Closed
MaisiKoleni opened this issue Mar 28, 2020 · 5 comments
Closed

Disallow student classes in trusted packages #15

MaisiKoleni opened this issue Mar 28, 2020 · 5 comments
Assignees
Labels
help wanted Extra attention is needed PRIO This issue has high priority security Related to security problems
Milestone

Comments

@MaisiKoleni
Copy link
Collaborator

Improve security by disallowing students to create classes in the whitelisted packages in the SecurityManager by configuring a custom Proxy for the ClassLoader which will throw SecurityExceptions in such cases.

Securing the testing process will be much simpler because we can trust classes in these packages blindly at runtime. However, this will not replace the Throwable-sanitization.

@MaisiKoleni MaisiKoleni added security Related to security problems PRIO This issue has high priority labels Mar 28, 2020
@MaisiKoleni MaisiKoleni self-assigned this Mar 28, 2020
@MaisiKoleni
Copy link
Collaborator Author

As a workaround, this can also be archived by telling the Maven compiler plugin to compile only classes in certain packages, like the main package of the exercise set in Artemis for example.

@MaisiKoleni MaisiKoleni added this to the 0.6.0 milestone Apr 6, 2020
@MaisiKoleni MaisiKoleni modified the milestones: 0.6.0, 0.5.1 Apr 19, 2020
@MaisiKoleni
Copy link
Collaborator Author

MaisiKoleni commented Apr 19, 2020

A short overview what is possible and what not:

  1. maven-compiler-plugin you can use include and exclude here, but the plugin will auto-include transitive sources that are not directly included themselves which defeats the security
  2. One could delete unwanted sources with e.g. the maven-clean-plugin. While that does ensure the security, students that use other packages will get even stranger build errors reporting that classes could not be found.
  3. Create a class loader that does not load classes of trusted packages from certain locations, e.g. outside of jar archives. However, enforcing the use of such a class loader dynamically only for student classes is very hard and error prone, possibly even more so than the path access and thread management. This is further complicated by the other test tool that create new class loaders on-the-fly.
  4. Write an ares-maven-plugin that checks which classes have been compiled and fails the build with an intelligible error message if one violates the package restrictions.
  5. Make Ares scan the class path at runtime for violations. This requires that Ares knows what classes are test classes and what are student classes.

Since 1 does not secure the build, it is not an option. 2 could be used, but would only work for maven builds, in an IDE that would have no effect. The same problem arises for 4. 3 would similar to the package restrictions of #13 only work during/before class loading and is hard to realize. For 5, I am unsure how well that could work.

In my eyes, a combination of 3 and 4 would be preferred.

Are there other options left? What would you prefer? I would be happy to hear more ideas.

@MaisiKoleni MaisiKoleni added the help wanted Extra attention is needed label Apr 19, 2020
@MaisiKoleni
Copy link
Collaborator Author

Currently, it is very likely it will be option 3 only.

@MaisiKoleni
Copy link
Collaborator Author

To some degree a workaround with ClassLoader.getSystemClassLoader().resources(trustedPackage.replace('.','/')) could help to find file locations that add, hide or override trusted packages. This is however difficult with all possible and different IDE and exercise testing setups.

@MaisiKoleni
Copy link
Collaborator Author

Current recommendation: use the Maven Enforcer Plugin and check that trusted packages do not exist in student code. (Should be done after compilation).

@MaisiKoleni MaisiKoleni self-assigned this Feb 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed PRIO This issue has high priority security Related to security problems
Projects
None yet
Development

No branches or pull requests

1 participant