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

chore(merge-back): 2.164.1 #31910

Merged
merged 5 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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"
}
Loading