dropbox / dependency-guard

A Gradle plugin that guards against unintentional dependency changes.
Apache License 2.0
378 stars 13 forks source link

Feature request: Support saving and checking hash or signature of dependency in report #103

Open amal opened 5 months ago

amal commented 5 months ago

dependency-guard does an awesome job of protecting projects from unwanted dependency changes.

But this way we know nothing about the actual dependency content and cannot protect against malicious supply chain attacks like the ones mentioned here:

Of course, we can use Gradle's support for package signatures. But it's hard to use properly and not supported by many Gradle plugins and library providers (including many Google and JetBrains packages).

By simply saving and checking the dependency package hash along with the package, name, and version, we can verify that this dependency has not been unexpectedly replaced! Using a hashing algorithm like xxHash this would be very fast and provide an order of magnitude higher level of security for any Gradle build with a super simple setup.

Additionally, we can store and check the signature hash for packages that provide one. Using truncated hashes (like for git commits) it will not bloat the dependency reports too much.

All of this can be optional and opt-in, disabled by default.

If this idea is welcome, I would be happy to provide a prototype/mvp pull request.

handstandsam commented 5 months ago

I agree that dependency verification is an important aspect of security. Gradle does provide the feature out of the box using: https://docs.gradle.org/current/userguide/dependency_verification.html#sub:enabling-verification. I don't find it very user friendly, but it does exist and work.

Adding this functionality to dependency-guard would increase the scope of this plugin which is something I'd want to try and avoid unless there is a community consensus.

Considerations: Dependency Guard also supports source based modules, not just artifacts which is a bit different. That being said, I don't know if it's a 100% fit, but I understand your request.

amal commented 5 months ago

@handstandsam I think this functionality fits well within the scope of the plugin, but I understand your concerns. I'll make an MVP pull request to show that it shouldn't significantly increase complexity and usability. Would you consider it?

handstandsam commented 5 months ago

I'd personally find this valuable as well in a tool. Before you spend a ton of time doing it, I've got a bunch of questions/comments to discuss so we can make sure this is something that could be implemented, and something that makes sense in this tool. Here are a bunch of questions/comments I thought of:

This could be a format (just an example).

org.jetbrains.kotlin:kotlin-stdlib:1.9.22 8c1a267 SHA1
org.jetbrains.kotlin:kotlin-stdlib:1.9.22 8c1a267 SHA1 https://repo1.maven.org/maven2

Future Questions: