aws / aws/aws-sdk-java-v2

sigv4 for Lattice unsigned-payload not supported for http requests

Aperta
#5,103 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
feature-request p2 service-api
Lingua principale
Java
Stelle
2.6k
Fork
1k
Merge medio
2g 9h
PR unite (30g)
51

Descrizione

### Describe the bug

When making http (not https) requests to lattice, the payload will always be signed because the signing logic will always sign the body when the protocol http and a streaming body is present. This isn't compatible with VPC Lattice which allows for GRPC over HTTP.

### Expected Behavior

requests to be signed with 'x-amz-content-sha256: UNSIGNED-PAYLOAD'

### Current Behavior

-H 'x-amz-content-sha256: STREAMING-AWS4-ECDSA-P256-SHA256-PAYLOAD'

### Reproduction Steps

```
SdkHttpFullRequest request = SdkHttpFullRequest.builder()
.protocol("HTTP")
.host("test.com:80")
.method(SdkHttpMethod.POST)
.encodedPath("/_status")
.contentStreamProvider(() - > new ByteArrayInputStream("{\"status\":\"ok\"}".getBytes()))
.build();

ExecutionAttributes ea = new ExecutionAttributes();
ea.putAttribute(AwsSignerExecutionAttribute.AWS_CREDENTIALS, EnvironmentVariableCredentialsProvider.create().resolveCredentials());
ea.putAttribute(AwsSignerExecutionAttribute.SERVICE_SIGNING_NAME, "vpc-lattice-svcs");
ea.putAttribute(S3SignerExecutionAttribute.ENABLE_PAYLOAD_SIGNING, false);

AwsCrtS3V4aSigner signer = AwsCrtS3V4aSigner.builder()
.defaultRegionScope(RegionScope.GLOBAL)
.build();

var signedRequest = signer.sign(request, ea);
for (var header: signedRequest.headers().entrySet()) {
for (var value: header.getValue()) {
System.out.print(" -H '" + header.getKey() + ": " + value + "'\n");
}
}
```

will print out some headers, notably

```
-H 'x-amz-content-sha256: STREAMING-AWS4-ECDSA-P256-SHA256-PAYLOAD'
```

### Possible Solution

In DefaultAwsCrtS3V4aSigner (and other signers) change logic to something like

```
private boolean shouldSignPayload(SdkHttpFullRequest request, ExecutionAttributes executionAttributes) {
Boolean payloadSigning =
executionAttributes.getAttribute(S3SignerExecutionAttribute.ENABLE_PAYLOAD_SIGNING);
if (payloadSigning != null && !booleanValue(payloadSigning)) {
return false;
}

if (!request.protocol().equals("https") && request.contentStreamProvider().isPresent()) {
return true;
}
```

to prioritize user choice

or look at `AwsSignerExecutionAttribute.SERVICE_SIGNING_NAME == vpc-lattice-svcs` to decide if the request body should be signed.

### Additional Information/Context

_No response_

### AWS Java SDK version used

2.21.20

### JDK version used

21.0.2

### Operating System and version

macOS 14.4.1

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia con la riproduzione nell’issue e leggi la logica di firma del payload in DefaultAwsCrtS3V4aSigner, quindi confronta il comportamento con quello degli altri signer menzionati. Il risultato atteso è una richiesta HTTP firmata con `x-amz-content-sha256: UNSIGNED-PAYLOAD` quando la firma del payload è disabilitata; verifica che la modifica non alteri il comportamento di HTTPS. L’issue non indica alcun file di test, quindi individua ed esegui i test pertinenti dei signer.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
aws, java
Ambito
backend-api-design, networking
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.