Repository navigation
Closed
Labels
questionQuestions that are neither investigations, bugs, nor enhancements
Description
I use aws lambda filter , and get 403 , I confirm I use right AK/SK , Region in my docker env, I'm not sure there have anything I missed .
myconfig:
admin:
access_log_path: /tmp/admin_access.log
address:
socket_address:
protocol: TCP
address: 127.0.0.1
port_value: 9901
static_resources:
listeners:
- name: listener_0
address:
socket_address:
protocol: TCP
address: 0.0.0.0
port_value: 10000
filter_chains:
- filters:
- name: envoy.filters.network.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.config.filter.network.http_connection_manager.v2.HttpConnectionManager
stat_prefix: ingress_http
access_log:
- name: envoy.file_access_log
config:
path: "/dev/stdout"
route_config:
name: local_route
virtual_hosts:
- name: local_service
domains: ["*"]
routes:
- match:
prefix: "/"
route:
cluster: service_bing
http_filters:
- name: envoy.filters.http.aws_lambda
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.aws_lambda.v3.Config
arn: "arn:aws:lambda:us-east-1:111111111111:function:hello_envoy"
payload_passthrough: true
# - name: envoy.filters.http.cors
# typed_config: {}
- name: envoy.filters.http.router
typed_config: {}
clusters:
- name: service_bing
connect_timeout: 10s
type: LOGICAL_DNS
# Comment out the following line to test on v6 networks
dns_lookup_family: V4_ONLY
lb_policy: ROUND_ROBIN
metadata:
filter_metadata:
com.amazonaws.lambda:
egress_gateway: true
load_assignment:
cluster_name: service_bing
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: lambda.us-east-1.amazonaws.com
port_value: 443
transport_socket:
name: envoy.transport_sockets.tls
typed_config:
"@type": type.googleapis.com/envoy.api.v2.auth.UpstreamTlsContext
sni: "*.amazonaws.com"
docker logs output:
[2020-05-22T06:38:46.302Z] "POST /2015-03-31/functions/hello_envoy/invocations HTTP/1.1" 403 - 14 192 1749 1748 "-" "curl/7.54.0" "8960a55f-500c-413a-856e-528019e0a2b9" "localhost:10000" "100.25.114.138:443"
curl test get error message:
{"message":"The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details."}
Metadata
Metadata
Assignees
Labels
questionQuestions that are neither investigations, bugs, nor enhancements
Activity
stevensu1977 commentedon May 23, 2020
this is envoy debug log,
2020-05-22 07:18:36.067][12][debug][aws] [source/extensions/common/aws/credentials_provider_impl.cc:41] Getting AWS credentials from the environment
[2020-05-22 07:18:36.067][12][debug][aws] [source/extensions/common/aws/credentials_provider_impl.cc:54] Found following AWS credentials in the environment: AWS_ACCESS_KEY_ID=AKIAYVBRQ5UTN2M9TBSR, AWS_SECRET_ACCESS_KEY=*****, AWS_SESSION_TOKEN=
[2020-05-23 00:26:19.868][12][debug][router] [source/common/router/router.cc:597] [C5][S8274519224793556409] router decoding headers:
':authority', 'localhost:10000'
':path', '/2015-03-31/functions/hello_envoy/invocations'
':method', 'POST'
':scheme', 'https'
'user-agent', 'curl/7.54.0'
'accept', '/'
'content-type', 'application/json'
'content-length', '312'
'x-forwarded-proto', 'http'
'x-request-id', 'cbc645fc-701f-4984-85e9-49f91106961c'
'x-amz-invocation-type', 'RequestResponse'
'x-amz-content-sha256', 'b867b51fb7fabda085c87dda7b0845d27e1fe7b0f37b8f93f56397d94af8e090'
'x-amz-date', '20200523T002600Z'
'authorization', 'AWS4-HMAC-SHA256 Credential=/20200523/us-east-1/lambda/aws4_request, SignedHeaders=accept;content-length;content-type;host;user-agent;x-amz-content-sha256;x-amz-date;x-amz-invocation-type;x-request-id, Signature=1585fa55648ec1170dd24b3c83453bd92b9eb598d907acad73cc2762bd8ba514'
'x-envoy-expected-rq-timeout-ms', '15000'
[2020-05-23 00:26:20.882][12][debug][http] [source/common/http/conn_manager_impl.cc:1767] [C5][S8274519224793556409] encoding headers via codec (end_stream=false):
':status', '403'
'date', 'Sat, 23 May 2020 00:26:20 GMT'
'content-type', 'application/json'
'content-length', '192'
'x-amzn-requestid', '13b01d25-1b7a-4f34-94f8-1ab5d3e123d8'
'x-amzn-errortype', 'InvalidSignatureException'
'x-envoy-upstream-service-time', '1013'
'server', 'envoy'
I'm not familiar with c++, so I try use python use this header , create post function send data to lambda endpoint(https://lambda.us-east-1.amazonaws.com), get same 403 error too.
stevensu1977 commentedon May 23, 2020
I missing "host" header , aws signer use default host "localhost:10000" for sign string, I use -H 'Host: lambda.us-east-1.amazonaws.com' , it's works !
curl -v -H "Content-Type:application/javascript" -H 'Host: lambda.us-east-1.amazonaws.com' -X POST -d @data.json localhost:10000
stevensu1977 commentedon May 23, 2020
I flound this error because signer use default header "localhost:10000" , but upstream is aws lambda endpoint , need set host same to as endpoint , etc "lambda.us-east-1.amazonaws.com".
I think customer already setup lambda arn etc. "arn:aws:lambda:us-east-1:111111111111:function:hello_envoy", if filter use host header from lambda ARN it's easy to customer, I create PR use lambda region as default host.
mattklein123 commentedon May 25, 2020
cc @marcomagdy
marcomagdy commentedon May 25, 2020
@stevensu1977 I copy pasted your configuration, changed only the function ARN and It works perfectly fine for me.
We don't need to set the host header. The upstream cluster takes care of that.
stevensu1977 commentedon May 27, 2020
@marcomagdy thank your quick feedback, but I think there still have issue , I get detail from trace log, you can see , if I don't use host header , envoy should use "host:localhost:10000" to aws auth signer and general "authorization" header for aws lambda filter , when I lambda filter invoke post to aws lambda endpoint this authorization is wrong (because request's host header is lambda.us-east-1.amazonaws.com, but authorization not match it), I use base image id "envoyproxy/envoy-dev:54dedadaa8aeac2963c7d47d46199ba3323527e5", if I missing something please tell me , thank you !
my test :
➜ serverless-controller curl -H "Content-Type:application/json" localhost:10000
{"message":"The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details."}%
➜ serverless-controller curl -H "Content-Type:application/json" -H "host:lambda.us-east-1.amazonaws.com" localhost:10000
"hello lambda from EKS. body is: "%
trace log:
[2020-05-27 08:40:13.124][11][debug][http] [source/extensions/common/aws/signer_impl.cc:66] Canonical request:
POST
/2015-03-31/functions/hello_envoy/invocations
accept:/
content-length:265
content-type:application/json
host:localhost:10000
user-agent:curl/7.54.0
x-amz-content-sha256:95f404cd309a87a04ae9702689de02ad5945535f9e57d02146e1abb144f21f1c
x-amz-date:20200527T084000Z
x-amz-invocation-type:RequestResponse
x-request-id:556c8dd5-e32b-41ad-8eb6-e700402d25d1
accept;content-length;content-type;host;user-agent;x-amz-content-sha256;x-amz-date;x-amz-invocation-type;x-request-id
95f404cd309a87a04ae9702689de02ad5945535f9e57d02146e1abb144f21f1c
':authority', 'localhost:10000'
':path', '/2015-03-31/functions/hello_envoy/invocations'
':method', 'POST'
':scheme', 'https'
'user-agent', 'curl/7.54.0'
'accept', '/'
'content-type', 'application/json'
'x-forwarded-proto', 'http'
'x-request-id', '556c8dd5-e32b-41ad-8eb6-e700402d25d1'
'x-amz-invocation-type', 'RequestResponse'
'content-length', '265'
'x-amz-content-sha256', '95f404cd309a87a04ae9702689de02ad5945535f9e57d02146e1abb144f21f1c'
'x-amz-date', '20200527T084000Z'
'authorization', 'AWS4-HMAC-SHA256 Credential=AKIAYVRRQ4TUN2M4TBSR/20200527/us-east-1/lambda/aws4_request, SignedHeaders=accept;content-length;content-type;host;user-agent;x-amz-content-sha256;x-amz-date;x-amz-invocation-type;x-request-id, Signature=7341f24dffc0d300ef6e5f69dea305670c2659734b2a2d7aec746cb580e2505c'
marcomagdy commentedon May 27, 2020
@stevensu1977 I was able to reproduce what you are seeing.
The problem will not happen if you pass any host header. It doesn't have to be Lambda's regional endpoint. In fact, if you pass
-H "Host: localhost"it will work just fine.The problem happens when you don't pass any host header, Envoy sets the header to
"localhost: 10000"and then the port section gets signed. On the other hand the AWS Lambda side won't include the port in the signature, therefore you end up with that error.So, I don't know if we need to make any changes to the filter. But if we do, it would be to
remove the
:<port>part from the host header before signing it.stevensu1977 commentedon May 28, 2020
@marcomagdy , thank your comments , I got it , you are right , send any host header it's work , I should close this issue and PR , thank's again.