Skip to content

aws-sigv4 signature covers non-existent Expect: header #11664

@apparentorder

Description

@apparentorder

I did this

curl -v
 --header 'expect:'
 --header 'Content-Type: application/json'
 --data '[ ... foo ... ]'
 --aws-sigv4 aws:amz:eu-central-1:appsync
 --user 'akid:secret'
 'https://xxx.appsync-api.eu-central-1.amazonaws.com/graphql'

I expected the following

Correct AWS SigV4, i.e. expect is not part of curl's generated SignedHeaders, as it is not part of the emitted request headers, like this:

authorization: AWS4-HMAC-SHA256
 Credential=xxx/20230812/eu-central-1/appsync/aws4_request,
 SignedHeaders=content-type;host;x-amz-date,
 Signature=xxx

But what actually happens is this:

authorization: AWS4-HMAC-SHA256
 Credential=xxx/20230812/eu-central-1/appsync/aws4_request,
 SignedHeaders=content-type;expect;host;x-amz-date,
 Signature=xxx

Per man page, using --header 'expect:' should remove that header. The header is indeed not present, but it seems that by forcing the removal of this non-existent header, it somehow gets added to the list of headers to be considered for aws-sigv4.

Additional context:

Some AWS APIs just ignore this (e.g. sts), but others report failure, e.g. Appsync GraphQL with IAM Auth:

  "errors" : [ {
    "errorType" : "IncompleteSignatureException",
    "message" : "'expect' is named as a SignedHeader, but it does not exist in the HTTP request."
  } ]

This seems to happen in libcurl – I've discovered it while playing around with Hurl, which explicitly sets Expect:.

curl/libcurl version

curl 8.0.1 (aarch64-amazon-linux-gnu) libcurl/8.0.1 OpenSSL/3.0.8 zlib/1.2.11 libidn2/2.3.2 nghttp2/1.51.0

operating system

Amazon Linux 2023

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions