Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(akamai): handle non-string user data in base64 decoding #5751

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jessealter
Copy link

Proposed Commit Message

fix(akamai): handle non-string user data in base64 decoding

Previously, user data that was base64-encoded was decoded as a string,
causing non-string data (e.g., gzipped user data) to raise an exception.
This change ensures that the output of b64decode is not decoded to a
string, passing along the decoded bytes unchanged.

Additional Context

Test Steps

  1. Deploy a Linode instance while supplying user-data that is gzipped and then base64 encoded. You may use any cloudconfig you like or the one provided which will set the hostname to it-worked-gzip, write to /root/proof.txt, and write to the "final_message".
curl -H "Content-Type: application/json" \
     -H "Authorization: Bearer $LINODE_API_TOKEN" \
     -X POST -d '{
       "region": "us-east",
       "type": "g6-nanode-1",
       "image": "linode/ubuntu22.04",
       "label": "cloud-init-test",
       "root_pass": "'"$PASS"'",
       "metadata": {
         "user_data": "H4sIAA759mYAAzWPwQ7CIBBE73zFWK9W71xN/AEPxlNDYEFiCwS2qRo/XrB62cxmX2Zmt3qMs+l1DNY7IbY4E+MWCwc1kfgLCc/9EvOdTO9ePjXwkj0TFKwfSSxtGZosUgA9kuKbxCHHyIdUp93zg+sFqFFMgSXe3xW4UtlVf6z+++Z98kGNmKgU5WqGZcpYi/pQSR2nNBJTEbaBww+U6I7tjzz54PCMc0Yrm8igsowya01kyGw6IT6RMgJw+QAAAA=="
       }
     }' \
     https://api.linode.com/v4/linode/instances
  1. You will see an exception is raised in /var/log/cloud-init.log when cloud-init attempts to decode the gzipped user data.

  2. Replace the installed cloud-init package with a patched release, or simply patch DataSourceAkamai.py.

  3. Run cloud-init clean, followed by cloud-init init.

  4. You should observe the cloudconfig being successfully decoded, decompressed, and applied.

Merge type

  • Squash merge using "Proposed Commit Message"
  • Rebase and merge unique commits. Requires commit messages per-commit each referencing the pull request number (#<PR_NUM>)

jessealter and others added 2 commits September 27, 2024 13:45
Previously, the Akamai data source did not permit gzipped user data
since all base64-encoded user data was assumed to be Unicode text.
With this change, base64-encoded gzipped user data is accepted.

Co-authored-by: Jolie Berner <jberner@akamai.com>
We are adding our names as Akamai employees. Akamai has previously
signed the CLA.

Co-authored-by: Jolie Berner <jberner@akamai.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant