Skip to content

Commit

Permalink
chore(merge-back): 2.164.1 (#31910)
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Oct 25, 2024
2 parents a1eef1d + e42cc02 commit e0615fe
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 11 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.v2.alpha.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [2.164.1-alpha.0](https://github.com/aws/aws-cdk/compare/v2.164.0-alpha.0...v2.164.1-alpha.0) (2024-10-25)

## [2.164.0-alpha.0](https://github.com/aws/aws-cdk/compare/v2.163.1-alpha.0...v2.164.0-alpha.0) (2024-10-24)


Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [2.164.1](https://github.com/aws/aws-cdk/compare/v2.164.0...v2.164.1) (2024-10-25)


### Bug Fixes

* enable node-fips compatible body checksums for S3 ([#31883](https://github.com/aws/aws-cdk/issues/31883)) ([290a499](https://github.com/aws/aws-cdk/commit/290a499f31413bd71eece4ad9f196eb5993747a9))

## [2.164.0](https://github.com/aws/aws-cdk/compare/v2.163.1...v2.164.0) (2024-10-24)


Expand Down
31 changes: 23 additions & 8 deletions packages/aws-cdk/lib/api/aws-auth/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ if (!regionUtil.getEndpointSuffix) {
throw new Error('This version of AWS SDK for JS does not have the \'getEndpointSuffix\' function!');
}

export interface S3ClientOptions {
/**
* If APIs are used that require MD5 checksums.
*
* Some S3 APIs in SDKv2 have a bug that always requires them to use a MD5 checksum.
* These APIs are not going to be supported in a FIPS environment.
*/
needsMd5Checksums?: boolean;
}

export interface ISDK {
/**
* The region this SDK has been instantiated for
Expand Down Expand Up @@ -56,7 +66,7 @@ export interface ISDK {
ec2(): AWS.EC2;
iam(): AWS.IAM;
ssm(): AWS.SSM;
s3(): AWS.S3;
s3(options?: S3ClientOptions): AWS.S3;
route53(): AWS.Route53;
ecr(): AWS.ECR;
ecs(): AWS.ECS;
Expand Down Expand Up @@ -173,19 +183,24 @@ export class SDK implements ISDK {
return this.wrapServiceErrorHandling(new AWS.SSM(this.config));
}

public s3(): AWS.S3 {
return this.wrapServiceErrorHandling(new AWS.S3({
public s3({
needsMd5Checksums: apiRequiresMd5Checksum = false,
}: S3ClientOptions = {}): AWS.S3 {
const config = { ...this.config };

if (!apiRequiresMd5Checksum) {
// In FIPS enabled environments, the MD5 algorithm is not available for use in crypto module.
// However by default the S3 client is using an MD5 checksum for content integrity checking.
// While this usage is technically allowed in FIPS (MD5 is only prohibited for cryptographic use),
// in practice it is just easier to use an allowed checksum mechanism.
// We are disabling the S3 content checksums, and are re-enabling the regular SigV4 body signing.
// SigV4 uses SHA256 for their content checksum. This configuration matches the default behavior
// of the AWS SDKv3 and is a safe choice for all users.
s3DisableBodySigning: false,
computeChecksums: false,
...this.config,
}));
// of the AWS SDKv3 and is a safe choice for all users, except in the above APIs.
config.s3DisableBodySigning = false;
config.computeChecksums = false;
}

return this.wrapServiceErrorHandling(new AWS.S3(config));
}

public route53(): AWS.Route53 {
Expand Down
15 changes: 14 additions & 1 deletion packages/aws-cdk/lib/api/garbage-collection/garbage-collector.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as crypto from 'node:crypto';
import * as cxapi from '@aws-cdk/cx-api';
import { S3 } from 'aws-sdk';
import * as chalk from 'chalk';
Expand Down Expand Up @@ -162,7 +163,19 @@ export class GarbageCollector {
// SDKs
const sdk = (await this.props.sdkProvider.forEnvironment(this.props.resolvedEnvironment, Mode.ForWriting)).sdk;
const cfn = sdk.cloudFormation();
const s3 = sdk.s3();

// Some S3 APIs in SDKv2 have a bug that always requires them to use a MD5 checksum.
// These APIs are not going to be supported in a FIPS environment.
// We fail with a nice error message.
// Once we switch this code to SDKv3, this can be made work again by adding
// `ChecksumAlgorithm: 'SHA256'` to the affected APIs.
// Currently known to affect only DeleteObjects (note the plural)
if (crypto.getFips() === 1) {
throw new Error('Garbage Collection is currently not supported in FIPS environments');
}
const s3 = sdk.s3({
needsMd5Checksums: true,
});

const qualifier = await this.bootstrapQualifier(sdk, this.bootstrapStackName);
const activeAssets = new ActiveAssetCache();
Expand Down
4 changes: 2 additions & 2 deletions version.v2.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": "2.164.0",
"alphaVersion": "2.164.0-alpha.0"
"version": "2.164.1",
"alphaVersion": "2.164.1-alpha.0"
}

0 comments on commit e0615fe

Please sign in to comment.