fix(rustfs): sanitize user-metadata in metadata=true object listing (#4592)

fix(rustfs): sanitize user-metadata in metadata=true object listing (#2743)

The console listing path (`list-type=2&metadata=true`) serializes each
object's user-metadata key as a raw XML *element name* and its value as
XML text without validation. User-metadata keys derived from HTTP
headers can legally contain characters that are illegal in an XML `Name`
(space, `$`, `%`, `#`, a leading digit, control bytes), and values can
contain C0 control characters that are illegal in XML 1.0 text.

A single object carrying such a key or value produced a malformed
`ListBucketResult` document, which the console's XML parser rejected
wholesale — so every object under that prefix vanished from the Web UI,
while plain `ListObjectsV2` (which never serializes user metadata) kept
working. The breakage appeared the moment any one object in a prefix had
XML-unsafe metadata and cleared once that object was removed, matching
the report.

Guard the serialization in `ObjectMetadataExtension::serialize_content`
(shared by the list-objects and list-versions metadata outputs): skip
entries whose key is not a valid XML element name, and strip
XML-1.0-illegal control characters from values. A single poison object
can no longer corrupt the whole listing document.
This commit is contained in:
Zhengchao An
2026-07-09 09:36:10 +08:00
committed by GitHub
parent e0f04f4621
commit 19a0a73fed
3 changed files with 127 additions and 1 deletions
Generated
+1
View File
@@ -8892,6 +8892,7 @@ dependencies = [
"percent-encoding",
"pin-project-lite",
"proptest",
"quick-xml",
"rand 0.10.2",
"rcgen",
"reqwest",