Skip to content

Conversation

@tsmock
Copy link
Contributor

@tsmock tsmock commented Dec 16, 2021

Description:

See https://nvd.nist.gov/vuln/detail/CVE-2021-44228.

Potential Impact:

There should be no significant impact -- the logging packages were shaded.

We are using sl4j in code, not log4j, so all we have to do is (a) update log4j and (b) optionally update sl4j.

It does appear that scripts and documents refer to -Dlog4j.configuration, which will make log4j 2.x read log4j 1.x configuration files.

Unit Test Approach:

N/A

Test Results:

Tests did pass.

See also:

@jwpgage
Copy link
Contributor

jwpgage commented Dec 16, 2021

Hey Taylor, have you tested this change in spark? Would like to see a world build before merging.

@tsmock
Copy link
Contributor Author

tsmock commented Dec 16, 2021

I'll do that as soon as I get atlas-generator/atlas-checks building again.

Both of them are looking for log4j-1.2.17 in osgeo, and it looks like osgeo removed the jar file for that release and replaced it with a -norce release. So I need to figure out which dependency is using it.

EDIT: I'm probably just going to do a general dependency update PR.
EDIT2: It turns out osgeo says it has log4j-1.2.17, but doesn't actually have it. Since it was the first repo on the list, it fails.

@atiannicelli
Copy link
Contributor

log4j 2.16.0 creates another vulnerability (CVE-2021-45105). So we need to upgrade to 2.17.0.

@tsmock
Copy link
Contributor Author

tsmock commented Dec 27, 2021

log4j 2.16.0 creates another vulnerability (CVE-2021-45105). So we need to upgrade to 2.17.0.

Since @jwpgage wants a world run before merging, I've gone ahead and done updated log4j to 2.17.0 in bdc815f, along with updating everything else that did not require source code changes.

Current CVE's in dependencies (most not from checkstyle/osmosis should be fixed in bdc815f, and will most likely require an update to atlas_checkstyle with the updated dependencies once this is merged in order to fully fix the issues):

Of note, checkstyle has not been updated since it means someone (probably me) will have to update the checkstyle settings (some settings got renamed, some got removed, some got added). Osmosis also has not been updated, since that will require source code changes, and it blocks protobuf.

EDIT: For Osmosis, I've made a PR at openstreetmap/osmosis#106 to update the osmosis dependencies. There are some dependencies that were not updated in that PR, since they would require more significant code rewriting (Netty 3.x to 4.x).

EDIT2: Checkstyle has been updated. Rather unfortunately, due to the way Atlas uses Checkstyle, the build will fail until a new version is released with the updated checkstyle dependency.

@tsmock tsmock force-pushed the cve-2021-44228 branch 2 times, most recently from 6f692ee to 437ed9b Compare December 29, 2021 21:41
@tsmock
Copy link
Contributor Author

tsmock commented Dec 29, 2021

For the checkstyle update, we are going to have to do one of two things:

  • Temporarily ignore the fact that the build is failing
  • Add the following (temporary) patch until a new release of Atlas is done. See 6e995c9.
index 4d5afdfb..57a64ea7 100644
--- a/build.gradle
+++ b/build.gradle
@@ -84,7 +81,7 @@ dependencies
     testImplementation packages.junit.params
     testImplementation packages.junit.vintage
 
-    checkstyle packages.atlas_checkstyle
+    checkstyle files("build/libs/${project.name}-${project.version}.jar")
     checkstyle packages.checkstyle
 
     shaded packages.log4j.api

@tsmock tsmock changed the title Update log4j to 2.16 to fix DDOS attacks Update log4j to 2.17.1 to fix DDOS attacks Dec 29, 2021
@tsmock tsmock marked this pull request as draft December 30, 2021 13:30
@tsmock tsmock marked this pull request as ready for review January 4, 2022 18:09
@tsmock
Copy link
Contributor Author

tsmock commented Jan 4, 2022

The run is taking a bit longer than expected. Both with and without the changes. @atiannicelli : What memory size are you using for your executors?

FTR, a large amount of time (28.7% of a 10+ minute profile run, more like 40% if you discount some native methods) is spent in https://github.com/osmlab/atlas/blob/dev/src/main/java/org/openstreetmap/atlas/utilities/filters/AtlasEntityPolygonsFilter.java#L236 . The amount of time spent with the dependency updates and without the dependency updates appeared to be about the same.

10+ minute run, with dependency updates

I'm going to do a full NZL run without the dependency updates on my hardware. And then I'll do one with the dependency updates.

@tsmock
Copy link
Contributor Author

tsmock commented Jan 12, 2022

OK. I've done a few runs with NZL (./gradlew run, and a standalone spark cluster, I did not save timings from spark cluster)

Timings from ./gradlew run

  • 43956s (original)
  • 48499s (original)
  • 47463s (updates)
  • 49334s (updates)

I'm uncertain what happened with the two original runs (10%+ difference), however, the second non-updated run was about the same as the two runs with updates. It could be a simple as different software running on the laptop used.

@atiannicelli
Copy link
Contributor

@jwpgage would you help to get this reviewed? @tsmock seems to have done a thorough update of many of the dependencies for Atlas that would bring it up to a level that would eliminate many CVE exposures.
Please let us know if there is any testing that we can do to help this get through the approval process.

@adahn6
Copy link
Contributor

adahn6 commented Jan 12, 2022

Due to the significant changes to dependencies here, I want to hold off on merging this for now. Log4j 1.x (our current dependency) is unaffected by this vulnerability, though it is unsupported now and it would be good to migrate soon. I realize the benefits of upgrading seem urgent, but Spark in particular is going to force-downgrade to Log4j 1.x anyway, so this yields a lot of changes to our dependency tree for minimal overall improvements. I know https://issues.apache.org/jira/browse/SPARK-6305 and apache/spark#34895 are scheduled for release in April, so it seems wise to wait until that's released to target testing and ensuring complete compatibility.

@adahn6
Copy link
Contributor

adahn6 commented Jan 12, 2022

@tsmock there's also a few changes here that seem unrelated to the log4j changes-- do you mind splitting those out into separate PRs? it will help make this one a bit easier to deal with if we need to rollback or debug

@adahn6
Copy link
Contributor

adahn6 commented Jan 12, 2022

I'll try to keep reviewing this over the next few days-- haven't been ignoring it, but it's a big changeset and there's a lot of backlog from the holidays

@tsmock
Copy link
Contributor Author

tsmock commented Jan 12, 2022

@tsmock there's also a few changes here that seem unrelated to the log4j changes-- do you mind splitting those out into separate PRs? it will help make this one a bit easier to deal with if we need to rollback or debug

The problem is that many of the changes are due to to some dependencies needing code updates.
Of specific note is the update of Gradle to 7.3.3 forces known-bad log4j versions out of the dependency tree. The gradle build script was not kept up-to-date (but the changes made ended up being very similar to those already made in atlas-generator, IIRC).

Beyond that, the checkstyle update forced some changes (due to fixed/new checks), and the update for osmosis forced an update to some classes (for the most part, renaming release to close).

With that being said, I can split it out into different changes, but I'll go ahead and rebase so that the commits are (a) in logical order and (b) in logical chunks (in other words, so that the squash doesn't have to happen).

@tsmock
Copy link
Contributor Author

tsmock commented Jan 12, 2022

OK. I've force-pushed only the log4j changes.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@adahn6
Copy link
Contributor

adahn6 commented Jan 13, 2022

@tsmock there's also a few changes here that seem unrelated to the log4j changes-- do you mind splitting those out into separate PRs? it will help make this one a bit easier to deal with if we need to rollback or debug

The problem is that many of the changes are due to to some dependencies needing code updates. Of specific note is the update of Gradle to 7.3.3 forces known-bad log4j versions out of the dependency tree. The gradle build script was not kept up-to-date (but the changes made ended up being very similar to those already made in atlas-generator, IIRC).

Beyond that, the checkstyle update forced some changes (due to fixed/new checks), and the update for osmosis forced an update to some classes (for the most part, renaming release to close).

With that being said, I can split it out into different changes, but I'll go ahead and rebase so that the commits are (a) in logical order and (b) in logical chunks (in other words, so that the squash doesn't have to happen).

ah, okay, I didn't realize that, but it makes sense. sorry for the hassle, we've had to rollback issues before so I'm always a little cautious about big changes. let me merge this and do a couple runs myself, then if everything looks good I'll go ahead and release and we can start reviewing the other dependency updates

@adahn6 adahn6 merged commit fb8a582 into osmlab:dev Jan 13, 2022
@tsmock tsmock deleted the cve-2021-44228 branch January 13, 2022 17:00
@tsmock
Copy link
Contributor Author

tsmock commented Jan 13, 2022

Fair enough. My test process was with atlas-checks -- I modified settings.gradle to include atlas/atlas-generator builds (which replace the pinned versions of both), and then used a local copy of NZL atlas files for testing.

adahn6 added a commit that referenced this pull request Mar 16, 2022
* Update dependencies

This only updates dependencies that did not require code rewriting.

Dependencies that require code rewriting include osmosis, which blocks
protobuf.

Signed-off-by: Taylor Smock <[email protected]>

* Fix broken BeanUtils test

BeanUtils 1.9.2 added the ability to prevent access to the `class` field. BeanUtils 1.9.4
prevented this by default. The specific test used the `class` field to
check for non-instantiable object handling.

Signed-off-by: Taylor Smock <[email protected]>

* Update to Osmosis 0.48.3 from 0.44.1

This required updating some classes, as one of the primary differences
is support for Java 8 AutoCloseable.

Signed-off-by: Taylor Smock <[email protected]>

* Update checkstyle

Signed-off-by: Taylor Smock <[email protected]>

* Gradle: add missing dependencies

Also, some prework for Gradle 7.x.

Signed-off-by: Taylor Smock <[email protected]>

* Update Gradle to 7.3.3

Signed-off-by: Taylor Smock <[email protected]>

* Dependency updates

Signed-off-by: Taylor Smock <[email protected]>

Co-authored-by: Samuel Gass <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants