awslabs/amazon-eks-ami

bug: /usr/bin/imds fails with printf format in user-data

Closed this issue · 1 comments

What happened:
I use /usr/bin/imds latest/user-data to get the instance user-data and get the error /usr/bin/imds: line 40: printf: `D': invalid format character at some point.
My user-data contains an URL with the sequence %3D ("=") which get interpreted by the "printf" command in the imds script and then fails.

What you expected to happen:

No error and the full user-data returned.

How to reproduce it (as minimally and precisely as possible):

  1. Create an instance with user-data containing "%D" (I use karpenter)
  2. On the instance, run imds latest/user-data
  3. See error

Environment:

  • AWS Region: N/A
  • Instance Type(s): N/A
  • Cluster Kubernetes version: N/A
  • Node Kubernetes version: 1.30
  • AMI Version: Amazon Linux 2023.6.20241111

I do not think that calling printf "$(cat $OUTPUT_FILE)\n" with no additional arguments is needed. A simple cat $OUTPUT_FILE; echo should be sufficient.

printf "$(cat $OUTPUT_FILE)\n"

This is not blocking as I can read the user-data from the cloud-init command or file directly.

@vflaux thanks for the report! Should be fixed 👍