spring-cloud / spring-cloud/spring-cloud-vault

AWS error making upstream request: received error code 403 from STS: The security token included in the request is expired

Open
#735 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
291
Forks
152
Avg merge
11h 24m
Merged PRs (30d)
3

Description

Hello,
i use vault v1.17.5 and org.springframework.cloud:spring-cloud-vault-dependencies:4.0.1 with org.springframework.vault:spring-vault-core:3.1.2

When using kv_v1 secrets i get an error after 6 hours and i don’t know why.
Until the 6 hour mark the kv-secrets are refreshed regularly and auth/token/renew-self
and auth/aws-iam/login are called successfully every 1 hour.

But after 6 hours i get “error making upstream request: received error code 403 from STS: The security token included in the request is expired”:

{
    "auth": {
        "policy_results": {
            "allowed": true
        },
        "token_type": "default"
    },
    "request": {
        "data": {
            "iam_http_request_method": "POST",
            "iam_request_body": "QWNwNi0xNQ==",
            "iam_request_headers": "eyJBdJdfQ==",
            "iam_request_url": "aHR0vbS8=",
            "role": "studiomiddleware-api-dev"
        },
        "id": "1bf4dec9-203d-64b7-faa7-72abdcd5316f",
        "mount_accessor": "auth_aws_ec607cf2",
        "mount_class": "auth",
        "mount_point": "auth/aws-iam/",
        "mount_running_version": "v1.17.5+builtin.vault",
        "mount_type": "aws",
        "namespace": {
            "id": "root"
        },
        "operation": "update",
        "path": "auth/aws-iam/login",
        "remote_address": "10.61.72.126",
        "remote_port": 57848
    },
    "response": {
        "data": {
            "error": "error making upstream request: received error code 403 from STS: <ErrorResponse xmlns=\"https://sts.amazonaws.com/doc/2011-06-15/\">\n  <Error>\n    <Type>Sender</Type>\n    <Code>ExpiredToken</Code>\n    <Message>The security token included in the request is expired</Message>\n  </Error>\n  <RequestId>52673536-1adc-4942-b253-7e09ed4d24aa</RequestId>\n</ErrorResponse>\n"
        },
        "mount_accessor": "auth_aws_ec607cf2",
        "mount_class": "auth",
        "mount_point": "auth/aws-iam/",
        "mount_running_plugin_version": "v1.17.5+builtin.vault",
        "mount_type": "aws"
    },
    "time": "2024-09-20T17:47:55.325205678Z",
    "type": "response"
}

This doesnt correspond to the ttl of the “aws-iam” auth backend which is set to 3 hours and also not to the roles STS 1 hour maximum ttl.

I don’t understand where this 6 hour expiration comes from.
Anybody have an idea?

spring boot config:

# General
spring:
  cloud:
    vault:
      enabled: true
      host: vault.dev.local
      port: 8200
      scheme: https
      authentication: AWS_IAM
      aws-iam:
        role: studiomiddleware-api-dev
        aws-path: aws-iam
      kv:
        enabled: true
      session:
        lifecycle:
          enabled: true
          refresh-before-expiry: 2m
          expiry-threshold: 4m
      config:
        lifecycle:
          enabled: true
          min-renewal: 30s # does not refresh more frequently than this
          expiry-threshold: 2m # attempts to renew the secrets this much time before they expire
  config:
    import: vault://secret/studiomiddleware-api/dev

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the AWS_IAM authentication flow at auth/aws-iam/login and the Spring Cloud Vault session and config lifecycle settings shown in the report. Reproduce the issue with the stated Vault, Spring Cloud Vault, and spring-vault-core versions, then trace renewals through the six-hour boundary. Done means identifying the source of the expired STS token and documenting or correcting the behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, java, spring
Domain
authentication, backend, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.