AWS lambda high security documentation change
Summary
Added documentation about Log4j patch for Log4Shell vulnerability (CVE-2021-44228), updated tiered compilation details, added Shenandoah GC configuration, and new sections about AOT/CDS caches
Security assessment
The change explicitly addresses the Log4Shell vulnerability (CVE-2021-44228) by documenting Lambda's built-in patch and providing guidance for mitigation. This is a direct reference to a critical security vulnerability (CVSS 10.0) that allowed remote code execution. The documentation also warns about runtime version dependencies for the patch.
Diff
diff --git a/lambda/latest/dg/java-customization.md b/lambda/latest/dg/java-customization.md index a8f0c6d18..6f57d2eb3 100644 --- a//lambda/latest/dg/java-customization.md +++ b//lambda/latest/dg/java-customization.md @@ -5 +5 @@ -Understanding the JAVA_TOOL_OPTIONS environment variable +Understanding the JAVA_TOOL_OPTIONS environment variableLog4j patch for Log4ShellAhead-of-Time (AOT) and CDS caches @@ -14,0 +15,4 @@ This page describes settings specific to Java functions in AWS Lambda. You can u + * Log4j patch for Log4Shell + + * Ahead-of-Time (AOT) and CDS caches + @@ -24 +28 @@ In Java, Lambda supports the `JAVA_TOOL_OPTIONS` environment variable to set add -Tiered compilation is a feature of the Java virtual machine (JVM). You can use specific tiered compilation settings to make best use of the JVM's just-in-time (JIT) compilers. Typically, the C1 compiler is optimized for fast start-up time. The C2 compiler is optimized for best overall performance, but it also uses more memory and takes a longer time to achieve it. +Tiered compilation is a feature of the Java virtual machine (JVM). You can use specific tiered compilation settings to make best use of the JVM's just-in-time (JIT) compilers. Typically, the C1 compiler is optimized for fast start-up time. The C2 compiler is optimized for best overall performance, but it also uses more memory and takes a longer time to achieve it. There are 5 different levels of tiered compilation. At Level 0, the JVM interprets Java byte code. At Level 4, the JVM uses the C2 compiler to analyze profiling data collected during application startup. Over time, it monitors code usage to identify the best optimizations. @@ -26 +30 @@ Tiered compilation is a feature of the Java virtual machine (JVM). You can use s -There are 5 different levels of tiered compilation. At Level 0, the JVM interprets Java byte code. At Level 4, the JVM uses the C2 compiler to analyze profiling data collected during application startup. Over time, it monitors code usage to identify the best optimizations. +Customizing the tiered compilation level can help you tune your Java function performance. For small functions that execute quickly, setting the tiered compilation to level 1 can help improve cold start performance by having the JVM use the C1 compiler. This setting quickly produces optimized native code but it doesn't generate any profiling data and never uses the C2 compiler. For larger, computationally-intensive functions, setting tiered compilation to level 4 maximizes overall performance at the expense of additional memory consumption and additional optimization work during the first invokes after each Lambda execution environment is provisioned. @@ -28,3 +32 @@ There are 5 different levels of tiered compilation. At Level 0, the JVM interpre -Customizing the tiered compilation level can help you reduce Java function cold start latency. For example, set the tiered compilation level to 1 to have the JVM use the C1 compiler. This compiler quickly produces optimized native code but it doesn't generate any profiling data and never uses the C2 compiler. - -In the Java 17 runtime, the JVM flag for tiered compilation is set to stop at level 1 by default. For the Java 11 runtime and below, you can set the tiered compilation level to 1 by doing the following steps: +For Java 11 runtimes and below, Lambda uses the default JVM tiered compilation settings. For Java 17 and Java 21, Lambda configures the JVM to stop tiered compilation at level 1 by default. From Java 25, Lambda still stops tiered compilation at level 1 by default, except when using SnapStart or Provisioned concurrency, in which case the default JVM settings are used. This improves performance for SnapStart and Provisioned concurrency without incurring a cold start penalty since tiered compilation is performed outside of the invoke path in these cases. To maximize this benefit, you can use priming - executing code paths during function initialization to trigger JIT before taking the SnapStart snapshot or when Provisioned Concurrency execution environments are pre-provisioned. For further information, see the blog post [Optimizing cold start performance of AWS Lambda using advanced priming strategies with SnapStart](https://aws.amazon.com/blogs/compute/optimizing-cold-start-performance-of-aws-lambda-using-advanced-priming-strategies-with-snapstart/). @@ -65,0 +68,19 @@ For example, if your workload uses more memory and multiple CPUs, consider using +If your workload has many short-lived objects, you may benefit from lower memory consumption by enabling the generational mode of the Shenandoah garbage collector introduced in Java 25. To do this, append the following to the value of your `JAVA_TOOL_OPTIONS` environment variable: + + + -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational + +## Log4j patch for Log4Shell + +Lambda runtimes for Java 8, 11, 17, and 21 include a patch to mitigate the Log4Shell vulnerability (CVE-2021-44228) in Log4j, a popular Java logging framework. This patch incurs a cold start performance overhead. If you are using a patched version of Log4j (version 2.17.0 or later), you can disable this patch to improve cold start performance. To disable the patch, set the `AWS_LAMBDA_DISABLE_CVE_2021_44228_PROTECTION` environment variable to `true`. + +Starting from Java 25, Lambda runtimes no longer include the Log4Shell patch. You must verify you are using Log4j version 2.17.0 or later. + +## Ahead-of-Time (AOT) and CDS caches + +Starting with Java 25, the Lambda runtime includes an Ahead-of-Time (AOT) cache for the Java runtime interface client (RIC), a runtime component which actively polls for events from the Lambda Runtime API. This improves cold start performance. + +AOT caches are specific to a JVM build. When Lambda updates the managed runtime, it also updates the AOT cache for the RIC. However, if you deploy your own AOT caches, these may be invalidated or result in unexpected behavior following a runtime update. We therefore strongly recommend not using AOT caches when using managed runtimes. To use AOT caches, you should deploy your functions using container images. + +AOT caches cannot be used with Class Data Sharing (CDS) caches. If you deploy CDS caches in your Lambda function, then Lambda disables the AOT cache. +