Every Signature is Broken: On the Insecurity of Microsoft Office’s OOXML Signatures
The paper analyses how OOXML digital signatures are verified and finds that the standard uses partial signatures and that rendering does not distinguish signed from unsigned content, so attackers can alter what a signed document displays while the signature still shows as valid. It also describes a universal signature forgery where a signature token from another source can be attached to an arbitrary document and displayed as validly signed.
Published on usenix.org
Every Signature is Broken: On the Insecurity of Microsoft Office’s OOXML Signatures Simon Rohlmann Ruhr University Bochum
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
Microsoft Office documents are among the most widely used containers for contracts, invoices and other documents whose authenticity matters. Since Office 2007, documents are stored by default as Office Open XML (OOXML) packages, and the OOXML standard (Ecma/ISO 29500) defines how those packages are digitally signed using a specific variant of XML signatures. The signature is meant to confirm that the content originated from the signer and has not been altered, and OOXML signatures are used by bodies such as the Defence Counterintelligence and Security Agency (DCSA), the government of Canada, the Federal register and the Federal Identity, Credential, and Access Management (FICAM) program.
An OOXML document is a zipped package of linked XML files. [Content_Types].xml maps each contained file to a content type and relative path. _rels/.rels references the main document file word/documents.xml and the property files docProps/app.xml and docProps/core.xml. The visible content lives mainly in word/document.xml, and word/_rels/document.xml.rels is a catalogue of all further files so the application knows which files are included and where to find them. word/styles.xml and word/fontTable.xml carry preferences such as character spacing and fonts. During rendering, word/document.xml contains ID-based references that must correspond to entries in word/_rels/document.xml.rels; referenced files such as word/styles.xml or word/fontTables.xml are pulled into the rendering process, and those files can in turn have their own relationship files under word/_rels/ referencing embedded fonts.
The signature itself is stored in an XML file with six main areas: Package Info, Office Info, Signature Properties, Signed Info, Signature Value and Key Info. Package Info lists protected files by name and path and always protects document.xml; for each file referenced in document.xml.rels the hash of the entire content is computed and stored, with the important exception that document.xml.rels itself is only partially signed. Office Info stores application preferences such as Office and Windows versions and resolution preferences. Signature Properties holds metadata about signature generation such as timestamps and certificates. Signed Info references Package Info, Office Info and Signature Properties, with a digest computed for each area, and all references are digitally signed. Signature Value stores the signature over Signed Info. Key Info refers to the keys used and is not signed, so attackers can manipulate it.
Verification starts at Signature Value: the application cryptographically verifies it using the public key from Key Info, which ensures the references and digest values of Package Info, Office Info and Signature Properties are unmodified. Then it computes the digest of each reference and compares with the stored values, then computes the hashes of all files referenced in Package Info and compares them, and finally validates the trustworthiness of the certificate in Key Info (Microsoft Office relies on the Windows Certificate Store for PKI-based trust validation).
Microsoft Office reflects the result in three UI layers. UI layer 1 is a banner shown on opening: valid (signature valid and certificate trusted), recoverable (signature valid but certificate not trusted) or invalid. UI layer 2 contains detailed status information. UI layer 3 shows the signer and distinguishes full from partial signatures for a valid document. When Microsoft Office signs a document itself, the status is shown as combination (1. a) despite the partial signature.
Figure 1 shows the signature stored as an XML file, the verification flow starting at Signature Value, and the rendering flow processing document.xml and document.xml.rels first to load all needed files.
Figure 2 shows the possible signature states across UI layers 1, 2 and 3: valid and trusted, valid but not trusted, and invalid, with the signer name and date and the full/partial distinction.
Setup
The work is a systematic analysis of the OOXML standard (6730 pages) and of its implementation in Microsoft Office and OnlyOffice Desktop. The authors define an attacker model with two capabilities, of which the attacker needs one:
- Trustfully Signed Document (ô): the attacker has access to a trustfully signed document, for example a signed law document publicly available on the Internet.
- Signing Oracle (¨): the attacker can choose, wholly or partly, the content to be signed, similar to a chosen-message attack, and the victim trusts that document's signature. The malicious payload must be invisible or not executed by the signing oracle, so the document appears legitimate; after signing, the attacker reveals the payload in a subsequent manipulation.
The attacker goal is data manipulation (N): change the rendered content without invalidating the signature status. An attack succeeds if the signature displays as valid and trustworthy while malicious content is rendered. The victim is assumed to expect a document signed by a trusted authority and to distrust warnings about invalid or untrusted signatures; documents signed with untrusted keys are excluded because they throw a warning.
The test environment was split into three system landscapes of virtual machines based on Windows 10 and Ubuntu 22.04.1, plus a hardware environment based on macOS Monterey. The signing oracle ran on a VM with Microsoft Office 2019 configured with a private key and public certificate. The attacker's system ran Microsoft Office 2019 in a VM without access to the signer's private key. Victim systems each had one examined Microsoft Office or OnlyOffice Desktop version installed and trusted the public certificate of the signing system, plus a macOS hardware environment with the examined versions.
Evaluated versions were Microsoft Office 2013, 2016, 2019, 2021 and 365 on Windows, Microsoft Office 2019, 2021 and 365 on macOS, and OnlyOffice Desktop 7.1 on Windows, macOS and Linux. The Windows builds were 15.0.5423.1000, 16.0.5278.1000, 16.0.10386.20017, 16.0.14332.20303 and 16.0.15028.20248; the macOS builds were all 16.61.22050700; the OnlyOffice builds were [redacted] on Windows, 7.1.1 (533) on macOS and [redacted] on Linux.
Google Workspace, OpenOffice, NeoOffice and the Digital Signature Services (DSS) were excluded for lack of native OOXML signature support. LibreOffice and Collabora Office recognise signed OOXML documents but throw a warning that the signature has problems even for validly signed documents, due to their default handling of partial signatures, so there is no valid-signature state to evaluate against and they were excluded too.
Finding it
The analysis ran in five phases.
Phase 1 examined the standard. It found that OOXML uses partial signatures that do not protect the entire package: relationship files contain unprotected parts, and the signature protects only individual strings indexed by unique IDs while the relationship file as a whole remains unsigned. This allows references to subsequently added files. The standard also defines a root element per XML file but does not forbid using elements defined for other files, so the body element responsible for rendered content can be defined in files other than document.xml, such as styles.xml. No distinction between signed and unsigned inserted content is made or distinguishable.
Phase 2 examined how Microsoft Office builds and signs packages. The signature is computed over all files in the word/ subdirectory and their reference in the relationship file, but [Content_Types].xml is unprotected, as are docProps/app.xml and docProps/core.xml, which contain among other things the creator. This yielded three possible points of attack: manipulation of existing but unsigned files, manipulation of the signature file, and manipulation by subsequently added files or references.
Phase 3 manipulated unsigned files. Changing content types and references in the relationship file, and gradually adding content to property files to change styles or add rendered content, caused Microsoft Office to consider the document corrupt as soon as the XML root element deviated from the content type or defined reference. Style elements or content inserted in property files were not displayed with any attack vector. Only metadata such as creator, last modifier and timestamps could be modified without invalidating the signature, which was expected since those files are not in the signature calculation. 24 documents were created; known threats were confirmed but no new attacks found.
Phase 4 manipulated the signature file. The characteristic of OOXML signatures is that the files to be signed and their reference strings are not directly placed in Signed Info; Signed Info references Package Info, which holds the digest values of multiple files. If the reference to Package Info is missing, the rendered content is not protected. The authors took an XML signature not created with Microsoft Office, valid but without the reference, and found a novel attack variant (Section 6.1). They also tested Key Confusion with untrusted keys and multiple elements in Key Info (one key to validate the signature, a second to validate trustworthiness), across different key formats and positions in Key Info, and found no vulnerability. XML Signature Wrapping, Signature Exclusion, Certificate Faking, Node Splitting and HMAC truncation were also tested; HMAC is not supported for OOXML signatures, and none of these yielded vulnerabilities. 211 documents were generated in this phase.
Figure 3 shows the signature flow generating multiple relations between the protected content; if any relation is not properly verified, attacks are possible.
Phase 5 examined partial signatures. Since [Content_Types].xml is not signed at all and relationship files are only partially signed, files can always be added to a signed package; the challenge is forcing the application to process and render them. Two questions were asked: do files exist that are rendered on opening but not referenced in document.xml, and can files referenced by document.xml be excluded from the signature computation? Both had solutions, giving the Content Injection Attack and the Content Masking Attack. The phase also noted that graphics can be external resources: only the URL is stored and the graphic is automatically reloaded on opening, so replacing the image stored under the URL changes the graphic in a signed document. Finally, the automatic repair feature was examined, leading to the Malicious Repair Attack; once repaired, documents cannot be saved without changing the file structure and invalidating the signature, so these are one-time attacks. 252 attack vectors emerged in this phase.
A simple Word document signed with Microsoft Office has at least two relationship files and one content-type file, with 9 references of different types and IDs and 3 default type definitions plus a content type per reference. Comments, footers, headers and footnotes extend the entries; embedded graphics or fonts add new relationship files. Test vectors were generated by permutations around questions such as: what happens if we exchange entries between relationship files, refer to files that do not exist, declare XML elements that do not match the schema, define multiple entries with the same or different IDs, reuse XML elements, have different content types, or combine manipulations? Signing correctly with an RSA or DSA key required a tool written in C# using the System.Security.Cryptography namespace. In total over 430 attack vectors produced 7 successful PoCs.
Exploitation
Content Injection Attack (CIA)
Requirement: a trustfully signed OOXML document (ô). The attack exploits partial signature coverage of document.xml.rels to add XML files and reference them. Added files normally do not influence content because they are not referenced in document.xml, but people.xml is processed without prior referencing, so arbitrary content (text, text boxes, graphics) can be added and shown.
Figure 4 shows the CIA on a signed document of a trusted entity, using people.xml to place the attacker's content over the original.
- The attacker requires an OOXML document validly signed by a trusted entity.
- The attacker creates a
people.xmlfile. - The attacker adds the
people.xmlfile into thewordsubfolder of the OOXML package. - The attacker manipulates
[Content_Types].xmland adds a reference to the filepeople.xml. This is permitted because[Content_Types].xmlis not signed. - The attacker manipulates
document.xml.relsby referencing the malicious filepeople.xml. This is also permitted because the relationship file is only partially signed. Already signed elements cannot be tampered with, but new files can be added without invalidating the signature. - (Optional) Graphics referenced by
people.xmlshould be declared inpeople.xml.relsand placed in theword/mediafolder.
After opening, the injected content is displayed and the trusted entity's signature still verifies. The attacker can hide original content and overlay it with arbitrary text, and can increase the original page count by injecting content; reducing the original number of pages is not possible. A limitation: selecting all content with CTRL+A / CTRL+C copies the entire content, including the original.
Content Masking Attack (CMA)
Requirement: a signing oracle (¨). The attacker creates a harmless-looking document that a trusted entity signs, then manipulates it and distributes it. The attacker removes the references to fontTable.xml or style.xml in document.xml.rels; since only referenced files are protected, the unsigned files can be manipulated later. Unlike CIA, the malicious document must be prepared before signing: text areas in document.xml should refer to fonts or styles defined in fontTable.xml or style.xml, otherwise the manipulations will not affect their appearance.
Figure 5 shows the attacker sending a harmless-looking document without references to contained fonts and styles to the signing oracle, so those files are not signed and can be manipulated afterwards.
Font Injection Attack (FIA)
OOXML documents can embed fonts. If used fonts are neither embedded nor present on the viewer's system, an operating system font as similar as possible can be selected automatically. The attacker creates custom fonts, for example with FontForge, choosing a different name from the system fonts (e.g. Arial1 instead of Arial). Within the custom fonts the attacker can remove the graphic representation of individual letters to hide text passages, or exchange letters to change passages. Using multiple custom fonts for different passages, the same content can display entirely differently depending on whether the custom fonts are embedded and referenced. The attacker removes the reference to the embedded fonts and passes the document to the signing oracle, which renders the harmless content because the custom fonts are not referenced and not installed. After signing, the attacker inserts the reference back, masking or changing the rendered content.
Style Injection Attack (SIA)
Similar to FIA, the attacker gets a self-created Word document signed without the reference to styles.xml, then adds the reference back to the relationship file without breaking the signature. Manipulating styles.xml varies the appearance of individual elements, for example selectively hiding or overlaying text passages. Content can also be injected via the body element in styles.xml. The impact is lower than CIA because a signing oracle is needed for every manipulated document.
Legacy Wrapping Attack (LWA)
Requirement: a signing oracle (¨). The goal is to use the signature of a legacy binary Word document (e.g. .doc) to display a valid signature over attacker-controlled content in a .docx. Legacy documents use the Compound File Binary format as container. When a Microsoft Office version supporting XML-based signatures signs a legacy document, it creates a folder _xmlsignatures containing a single file with a random number as file name, identical to the sig1.xml used by OOXML. The signature of a .doc includes 1Table, [0x01]CompObj, Data and WordDocument; the byte before CompObj has the value 1. Word requires every file in OOXML documents to have a content type in [Content_Types].xml, otherwise it considers the document corrupted and prompts for repair, and most non-printable ASCII characters including 0x01 cannot be used directly. A hex editor can change the 0x01 byte into a printable character, for example A, keeping the structure intact.
- The attacker creates a legacy document (
.doc) with content the signing oracle will agree to. - The attacker transforms the byte with value
0x01beforeCompObjinto a printable byte (in this caseA). - The signing oracle signs the document.
- The attacker creates a new
.docxdocument and chooses the content arbitrarily. - The attacker injects
1Table,ACompObj,DataandWordDocumentinto the root directory of the.docxpackage. - The attacker sets the content types to
application/octet-streamin[Content_Types].xml. - The attacker copies the
_xmlsignaturesfrom the signed.docdocument to the.docxpackage. - The attacker renames the signature file in
_xmlsignatures(whose name is a random number) tosig1.xml. - The attacker creates the
_xmlsignatures/origin.sigsand_xmlsignatures/_relsfile forsig1.xml. - The attacker adds the content types for
_xmlsignatures/origin.sigsand_xmlsignatures/sig1.xmlin[Content_Types].xml. - The attacker adds a digital signature relationship to
_rels/.rels.
Because a legacy document signed with a newer Microsoft Office produces an XML signature compatible with OOXML signatures, obtaining an OOXML signature over a legacy document lets the attacker insert the legacy document and signature into any OOXML document to obtain a universally valid signature. The victim sees a valid signature of a trusted entity while the attacker chooses the content arbitrarily.
Universal Signature Forgery (USF)
Requirement: a valid XML signature of a trusted entity, extracted from any other application that uses XML Signatures, such as signed ODF documents or SAML authentication tokens. Neither a trustfully signed document nor a signing oracle is needed.
- The attacker creates a self-signed OOXML document with arbitrary content. Self-signing is only used to let the application automatically create the correct references and hash values in Package Info.
- The attacker extracts the signature file from the OOXML package.
- The attacker replaces the Signed Info, Signature Value and Key Info with a valid XML signature of a trusted entity, for example from a signed ODF document. If the new Signed Info element contains references to internal objects within the XML signature, these must also be included.
- The attacker adds the manipulated signature file back to the OOXML package.
Figure 6 shows the attacker placing trustfully signed XML content and referencing it in Signed Info, so only that content is verified and the integrity verification of all files in the package is skipped.
On opening, the application verifies the stored digest values in Package Info against the existing files; since these match the attacker's content, the check succeeds. Since Signed Info is taken from a valid XML signature of a trusted entity, that validation also succeeds, and the certificate's trusted entity in Key Info is shown as the signer.
Malicious Repair Attack (MRA)
Only the relationships present at signing time are signed, so more relationships can be added while preserving the signature, producing documents with signed but not rendered files.
Duplicate Document Attack (DDA)
The attacker obtains a validly signed OOXML document and prepares a new OOXML document to be displayed instead. All files in the new document are renamed so they do not collide with default names. The attacker adds the files of the new package to the signed document and inserts the corresponding references into [Content_Types].xml, and adds a new relationship targeting the new document.xml. This is allowed because the relationship file is only partially signed. The attacker copies the document.xml.rels from the attacker's document and renames it so the relationship file name matches the renamed document.xml.
Evil Type Attack (ETA)
The attacker uses a signed Excel or PowerPoint document to inject the contents of a Word package. The attacker obtains a validly signed Excel or PowerPoint document, creates a Word document with freely definable content, copies the Word-related files into the signed document, copies the content types of the Word-related files into [Content_Types].xml, inserts the references of the Word package files into the relationship file of the signed document, and changes the file extension to .docx.
On opening, Microsoft Office prompts to repair the file because of the duplicate file structure, creates a new temporary document, and displays only the attacker's content, while signature verification is performed over the original content, so a valid signature of a trusted entity is displayed. Limitation: if the victim saves the repaired document, only the attacker's content is saved while the signature is kept over the original content, so the signature is invalid when reopened.
Root cause
Three issues underlie the specification attacks. OOXML uses partial signatures: relationship files are only partially signed, [Content_Types].xml is not signed at all, and only strings indexed by IDs are protected, so new files and references can be added after signing. The rendering flow does not distinguish signed from unsigned content, and the standard does not forbid placing the body element in files other than document.xml. The cryptographic verification is complex, with references to multiple elements and files, transformations, hash computations and public-key operations, and the signature verification adds another layer of references to the hash tree of XML signatures.
USF is an implementation flaw in the verification logic: the application does not verify that the files in the package are actually referenced in Signed Info, so a valid XML signature from any source yields a universally usable signature that provides no integrity protection over the package. MRA abuses the repair feature and the fact that only relationships present at signing time are signed. On macOS, no signature validation is performed at all.
Impact
All tested Office versions are vulnerable. On Windows, every tested Microsoft Office version is vulnerable to each attack, with the signature shown as valid and trusted in combination (1. a) for USF and (1. b) for the remaining attacks; the repair attacks are limited because they need the victim to accept the repair prompt. CIA and CMA overlay the original content, with the CTRL+A / CTRL+C limitation; LWA displays the attacker's content while the original signed content is not visible. USF gives the attacker complete control of the content with no indication of tampering and shows the original issuer of the XML signature as signer. Repair attacks require the victim to accept the repair prompt and are limited because saving invalidates the signature.
On macOS the result is worse: the UI layer 1 banner states the document is protected by a signature, an icon with the tooltip "This document contains signatures." is shown, and the document is locked for editing and read-only, but direct manipulation of document.xml is not detected and the hints remain identical. Removing all content from sig1.xml still shows the same indication, so manipulation is trivial and needs no special attack vectors. Further UI layers showing signer or signing date do not exist on macOS.
Figure 7 shows the macOS UI layer 1 stating the document is protected by a signature even when the signature file has no content.
OnlyOffice Desktop is fully vulnerable to CIA, LWA and the repair attacks. For CIA, the malicious people.xml is defined as a second main document in _rels/.rels with Id0; because of the lower ID compared with document.xml, OnlyOffice chooses people.xml as the main document, so only its content is displayed and the originally signed content is hidden, exploiting both the specification's partial signatures and an OnlyOffice implementation flaw allowing two correctly referenced main documents. OnlyOffice does not support embedded fonts, so FIA does not apply; SIA can hide predefined content but cannot inject new content, so it is limited vulnerable. USF fails because OnlyOffice checks that Signed Info contains a reference to Package Info. Repair attacks work without a prompt and the signature remains valid for both variants. OnlyOffice does not support graphics dynamically reloaded via URL.
A separate finding applies to signed OOXML documents in Microsoft Office: graphics added as external resources through a URL are automatically reloaded on opening, and only the URL is signed, so replacing the graphic stored under the URL changes the displayed image while the signature remains valid.
Fix
The authors propose one particular mitigation for each attack class, addressing its root cause. During coordinated disclosure the vulnerabilities were reported to Microsoft, OnlyOffice and the responsible standardization committee ISO/IEC JTC 1/SC 34. Microsoft acknowledged the vulnerabilities and awarded the research with a bug bounty, but decided the vulnerabilities do not require immediate attention and did not exclude a potential fix in the future. No feedback was received from OnlyOffice as of October 4th, 2022. Proof of concept files for all attacks are available at https://github.com/RUB-NDS/OOXML_Signature_Security.
Variants to test
- A positive result is the injected content rendering while the signature still shows as valid.
- Prepare a document whose text refers to fonts or styles, strip the references to
fontTable.xmlorstyle.xmlbefore signing, then restore them afterwards. A positive result is the appearance changing after signing without invalidating the signature. - Build custom fonts with removed or swapped glyphs under a name distinct from system fonts, sign without the font reference, then reinsert it. A positive result is hidden or altered text with a valid signature.
- Sign a legacy
.docafter changing the0x01byte beforeCompObjto a printable character, then transplant_xmlsignaturesinto an arbitrary.docxassig1.xmlwith the required content types and relationship. A positive result is the attacker's content shown under the trusted signature. - Replace Signed Info, Signature Value and Key Info in a self-signed OOXML package with a valid XML signature from an ODF document or SAML token. A positive result is the document displaying as validly signed by the original issuer.
- Add a second main document with a lower ID in
_rels/.relsalongsidedocument.xml. A positive result on an implementation that picks the lower ID is the second document being rendered while the signature stays valid. - Inject a Word package into a signed Excel or PowerPoint package and rename the extension to
.docx. A positive result is a repair prompt followed by the attacker's content under the original valid signature. - On macOS, edit
document.xmldirectly or emptysig1.xml. A positive result is the signature banner remaining unchanged.
What happened, in plain words
Microsoft Office is the program most people use to write documents, spreadsheets and presentations. Since 2007, Office saves its files in a format called Office Open XML, or OOXML for short. A file in this format is not one single thing: it is a zip archive, like a folder that has been squeezed into one file, and inside it there are several smaller files. Some of those inner files hold the text you see, some hold the fonts and colours, some hold information about who wrote the document, and one holds a digital signature if the document has been signed.
A digital signature is a mathematical stamp that lets a reader check two things: who signed the document, and whether anything inside it has changed since it was signed. Contracts, invoices and government forms rely on this. If you receive a signed invoice and the amount has been quietly changed, the signature is supposed to break and Office is supposed to warn you.
The researchers in this paper looked closely at how OOXML signatures are defined and how Microsoft Office actually checks them. They found that the checking is incomplete. In several different ways, an attacker can change what a signed document shows on screen while Office still displays the reassuring message that the document is signed and valid. They built working examples for every attack and tested them against many versions of Microsoft Office on Windows and macOS, and against a competing program called OnlyOffice. Every version they tested was vulnerable. On macOS the situation is worse than on Windows: Office there does not really check the signature at all, it only shows a banner saying the document is protected.
The rest of this article walks through the same material as the technical paper, but from the beginning. Every term is explained the first time it appears, and every step is described in plain language so you can follow it even if you have never studied security.
Background: what a signed Office document actually is
The zip package
When you save a Word document as .docx, you are saving a zip archive. You can prove this to yourself: rename the file so it ends in .zip and open it with any unzip tool. Inside you will see a small tree of folders and files. The paper describes the important ones:
[Content_Types].xmlis a list that tells Office what kind of file each entry is. Think of it as the label on each box inside a shipping crate: it says "this one is text", "this one is a picture", and so on._rels/.relsis a relationship file. A relationship file is a map: it says which inner file is the main document and where the other important parts live. The paper says it points toword/documents.xmland to two property files,docProps/app.xmlanddocProps/core.xml.word/document.xmlholds the visible content, the words on the page.word/_rels/document.xml.relsis a second relationship file, a catalogue of every further file the document uses, so the program knows what to load and where to find it.word/styles.xmlandword/fontTable.xmlhold preferences such as character spacing and fonts.
When Office opens the document, it renders it: it reads word/document.xml, follows the references in word/_rels/document.xml.rels, and pulls in the other files it needs. Some of those files can have their own relationship files under word/_rels/, for example to point at embedded fonts.
The signature file
The signature is itself an XML file stored inside the package. XML is a text format that uses tags in angle brackets, like <name>value</name>, to label pieces of data. The paper says the signature file has six main areas:
- Package Info lists the protected files by name and path. It always protects
document.xml. For every file referenced indocument.xml.rels, a hash of the whole file is computed and stored. A hash is a short fingerprint derived from a file's contents: change one character and the fingerprint changes completely. The important exception is thatdocument.xml.relsitself is only partially signed, which becomes central later. - Office Info stores application preferences, such as which Office and Windows versions were used and resolution settings.
- Signature Properties holds metadata about how the signature was made, such as timestamps and certificates. A certificate is a digital identity document, issued by an authority, that binds a public key to a person or organisation.
- Signed Info references Package Info, Office Info and Signature Properties, and a digest (another word for hash) is computed for each area. All these references are then digitally signed.
- Signature Value stores the actual cryptographic signature over Signed Info.
- Key Info points to the keys used to sign. Crucially, this area is not itself signed, so an attacker can change it.
How verification is supposed to work
When you open a signed document, Office is meant to do four things in order:
- Start at Signature Value and cryptographically check it using the public key taken from Key Info. This proves that the references and digest values in Package Info, Office Info and Signature Properties have not been altered.
- Compute the digest of each reference and compare it with the stored value.
- Compute the hash of every file listed in Package Info and compare it with the stored hash. This is what proves the files themselves are unchanged.
- Check that the certificate in Key Info is trustworthy. On Windows, Office relies on the Windows Certificate Store, the operating system's built-in list of trusted certificate authorities.
What the user sees
Office shows the result in three layers of user interface, which the paper calls UI layers:
- UI layer 1 is a banner shown when the document opens. It says the signature is valid (signature correct and certificate trusted), recoverable (signature correct but certificate not trusted), or invalid.
- UI layer 2 gives more detail about the status.
- UI layer 3 shows the signer's name and the signing date, and for a valid document distinguishes a full signature from a partial signature.
A partial signature means the signature covers only some of the files in the package, not all of them. When Microsoft Office signs a document itself, it shows the status as combination (1. a), meaning valid and trusted, even though the signature is partial.
Figure 1 shows the signature stored as an XML file, the verification flow starting at Signature Value, and the rendering flow processing document.xml and document.xml.rels first to load all needed files.
Figure 2 shows the possible signature states across UI layers 1, 2 and 3: valid and trusted, valid but not trusted, and invalid, with the signer name and date and the full/partial distinction.
How the research was set up
The researchers read the OOXML standard, which runs to 6730 pages, and then studied how real programs implement it. They defined an attacker model: a description of what the attacker can and cannot do. The attacker needs one of two capabilities:
- Trustfully Signed Document (ô): the attacker has a document that a trusted party has already signed. Such documents are often public, for example a signed law published on a government website.
- Signing Oracle (¨): the attacker can get a trusted party to sign a document whose content the attacker chooses, wholly or partly. This is like a chosen-message attack in cryptography: if you can ask a signer to stamp messages of your choosing, you can often abuse that. The catch is that the malicious part must be invisible or not executed when the trusted party signs, so the document looks legitimate. After signing, the attacker changes the document to reveal the payload.
The attacker's goal is data manipulation (N): change what the document displays without making the signature status go bad. An attack counts as successful if the signature shows as valid and trustworthy while the malicious content is what the victim sees. The victim is assumed to expect a document signed by a trusted authority and to distrust warnings about invalid or untrusted signatures. Documents signed with untrusted keys are excluded because they already throw a warning.
The test environment was split into three sets of virtual machines, based on Windows 10 and Ubuntu 22.04.1, plus a physical Mac running macOS Monterey. A virtual machine is a computer simulated inside another computer, which makes it easy to run many clean test systems. The signing oracle ran on a VM with Microsoft Office 2019 configured with a private key and public certificate. The attacker's system ran Microsoft Office 2019 in a VM without access to the signer's private key. Each victim system had one version of Office or OnlyOffice installed and trusted the public certificate of the signing system.
The versions tested were Microsoft Office 2013, 2016, 2019, 2021 and 365 on Windows, Microsoft Office 2019, 2021 and 365 on macOS, and OnlyOffice Desktop 7.1 on Windows, macOS and Linux. The Windows builds were 15.0.5423.1000, 16.0.5278.1000, 16.0.10386.20017, 16.0.14332.20303 and 16.0.15028.20248; the macOS builds were all 16.61.22050700; the OnlyOffice builds were [redacted] on Windows, 7.1.1 (533) on macOS and [redacted] on Linux.
Some programs were left out. Google Workspace, OpenOffice, NeoOffice and the Digital Signature Services (DSS) do not natively support OOXML signatures. LibreOffice and Collabora Office do recognise signed OOXML documents, but they show a warning that the signature has problems even for validly signed documents, because of how they handle partial signatures. That means there is no "valid signature" state to test against, so they were excluded too.
Finding the flaws
The analysis ran in five phases.
Phase 1: reading the standard
The first finding is that OOXML uses partial signatures that do not protect the whole package. Relationship files contain parts that are not signed. The signature protects only individual strings, indexed by unique IDs, while the relationship file as a whole stays unsigned. In practice this means an attacker can add references to new files after signing.
The second finding is about where content can live. The standard defines a root element for each XML file, but it does not forbid using elements defined for other files. So the body element, which is what actually holds rendered content, can be defined in files other than document.xml, such as styles.xml. Nothing in the process distinguishes signed from unsigned inserted content, and nothing makes that distinction visible.
Phase 2: how Office signs in practice
The researchers confirmed that Office signs all files in the word/ subdirectory and their reference in the relationship file. But [Content_Types].xml is unprotected, and so are docProps/app.xml and docProps/core.xml, which contain things like the creator's name. This gave three possible points of attack: changing existing but unsigned files, changing the signature file, and adding new files or references after signing.
Phase 3: changing unsigned files
The team changed content types and references in the relationship file, and gradually added content to the property files to try to change styles or add rendered content. As soon as the XML root element in a property file did not match the content type or the defined reference, Office treated the document as corrupt. Style elements or content inserted in property files were never displayed. Only metadata such as creator, last modifier and timestamps could be changed without breaking the signature, which was expected because those files are not part of the signature calculation. 24 documents were created in this phase; known threats were confirmed but no new attacks were found.
Phase 4: changing the signature file
A key characteristic of OOXML signatures is that the files to be signed and their reference strings are not placed directly in Signed Info. Signed Info points to Package Info, and Package Info holds the digest values of the files. If the reference to Package Info is missing, the rendered content is not protected at all. The researchers took an XML signature that was not created by Microsoft Office, valid but without that reference, and found a new attack variant, described later as Universal Signature Forgery.
They also tested several known attacks against XML signatures. Key Confusion means supplying two keys, one to make the signature check pass and another to make the signer look trustworthy; they tried different key formats and positions in Key Info and found no vulnerability. XML Signature Wrapping means rearranging the XML so the verifier checks one element while the application uses another; no vulnerability. Signature Exclusion means simply removing parts of the signature to see whether the verifier gets confused; no vulnerability. Certificate Faking means using an untrusted key and hoping the trust check is skipped; no vulnerability. Node Splitting means inserting a comment or entity so that one part of the program reads a value differently from another; no vulnerability. HMAC truncation was also considered, but HMAC is not supported for OOXML signatures. 211 documents were generated in this phase.
Figure 3 shows the signature flow generating multiple relations between the protected content; if any relation is not properly verified, attacks are possible.
Phase 5: abusing partial signatures
Because [Content_Types].xml is not signed at all and relationship files are only partially signed, files can always be added to a signed package. The hard part is making the application actually process and render them. The team asked two questions: are there files that get rendered on opening but are not referenced in document.xml, and can files that are referenced by document.xml be excluded from the signature calculation? Both had answers, giving the Content Injection Attack and the Content Masking Attack.
This phase also noted that graphics can be external resources. Only the URL of the graphic is stored in the document, and the graphic is automatically reloaded when the document opens. So replacing the image stored at that URL changes the picture in a signed document without touching the signature.
Finally, the automatic repair feature was examined. Office has a repair mode that tries to fix a damaged file. This led to the Malicious Repair Attack. Once a document has been repaired, it cannot be saved without changing the file structure and invalidating the signature, so these attacks are one-time only. 252 attack vectors came out of this phase.
How the test documents were generated
A simple Word document signed with Microsoft Office has at least two relationship files and one content-type file, with 9 references of different types and IDs, and 3 default type definitions plus a content type for each reference. Adding comments, footers, headers and footnotes extends those entries; embedding graphics or fonts adds new relationship files. The team generated test documents by permuting these entries around questions such as: what happens if we exchange entries between relationship files, refer to files that do not exist, declare XML elements that do not match the schema, define multiple entries with the same or different IDs, reuse XML elements, use different content types, or combine several of these manipulations? Signing correctly with an RSA or DSA key required a small tool written in C# using the System.Security.Cryptography namespace. In total, over 430 attack vectors produced 7 successful proofs of concept.
The attacks
Content Injection Attack (CIA)
This attack needs a trustfully signed OOXML document (ô). It abuses the partial signature coverage of document.xml.rels to add XML files and reference them. Normally an added file has no effect because it is not referenced in document.xml. But people.xml, a file meant to hold the names of people who commented, is processed without being referenced first. So arbitrary content, such as text, text boxes or graphics, can be added and shown.
Figure 4 shows the CIA on a signed document of a trusted entity, using people.xml to place the attacker's content over the original.
- The attacker needs an OOXML document validly signed by a trusted entity.
- The attacker creates a
people.xmlfile. - The attacker adds
people.xmlinto thewordsubfolder of the package. - The attacker edits
[Content_Types].xmland adds a reference topeople.xml. This works because[Content_Types].xmlis not signed. - The attacker edits
document.xml.relsto referencepeople.xml. This also works because the relationship file is only partially signed. Already signed elements cannot be changed, but new files can be added without invalidating the signature. - Optionally, graphics referenced by
people.xmlshould be declared inpeople.xml.relsand placed in theword/mediafolder.
After opening, the injected content is displayed and the trusted entity's signature still verifies. The attacker can hide original content and overlay it with arbitrary text, and can increase the page count by injecting content; reducing the original number of pages is not possible.
Content Masking Attack (CMA)
This attack needs a signing oracle (¨). The attacker creates a harmless-looking document that a trusted entity signs, then manipulates it and sends it on. The attacker removes the references to fontTable.xml or style.xml in document.xml.rels; since only referenced files are protected, the unsigned files can be changed later. Unlike CIA, the malicious document must be prepared before signing: text areas in document.xml should refer to fonts or styles defined in fontTable.xml or style.xml, otherwise the later changes will not affect how they look.
Figure 5 shows the attacker sending a harmless-looking document without references to contained fonts and styles to the signing oracle, so those files are not signed and can be manipulated afterwards.
Font Injection Attack (FIA)
OOXML documents can embed fonts, meaning the font file travels inside the document. If a used font is neither embedded nor installed on the viewer's computer, the operating system can pick the closest similar font automatically. The attacker creates custom fonts, for example with a free tool called FontForge, and gives them a different name from the system fonts, such as Arial1 instead of Arial. Inside the custom font, the attacker can remove the drawing of individual letters to hide text passages, or swap letters to change passages. By using several custom fonts for different passages, the same content can look completely different depending on whether the custom fonts are embedded and referenced. The attacker removes the reference to the embedded fonts and passes the document to the signing oracle, which sees the harmless content because the custom fonts are not referenced and not installed. After signing, the attacker puts the reference back, which masks or changes the rendered content.
Style Injection Attack (SIA)
Similar to FIA, the attacker gets a self-created Word document signed without the reference to styles.xml, then adds the reference back to the relationship file without breaking the signature. Editing styles.xml changes how individual elements look, for example hiding or overlaying text passages. Content can also be injected through the body element in styles.xml. The impact is lower than CIA because a signing oracle is needed for every manipulated document.
Legacy Wrapping Attack (LWA)
This attack needs a signing oracle (¨). The goal is to use the signature of an old binary Word document (a .doc file) to display a valid signature over attacker-controlled content in a .docx file. Old .doc files use a different container format called Compound File Binary. When a Microsoft Office version that supports XML-based signatures signs a legacy document, it creates a folder _xmlsignatures containing a single file whose name is a random number. That file is identical in structure to the sig1.xml used by OOXML. The signature of a .doc covers 1Table, [0x01]CompObj, Data and WordDocument, and the byte before CompObj has the value 1. Word requires every file in an OOXML document to have a content type in [Content_Types].xml, otherwise it treats the document as corrupt and offers to repair it, and most non-printable ASCII characters, including 0x01, cannot be used directly. A hex editor, a tool for editing raw bytes, can change the 0x01 byte into a printable character such as A, keeping the structure intact.
- The attacker creates a legacy document (
.doc) with content the signing oracle will agree to. - The attacker changes the byte with value
0x01beforeCompObjinto a printable byte, in this caseA. - The signing oracle signs the document.
- The attacker creates a new
.docxdocument and chooses the content arbitrarily. - The attacker injects
1Table,ACompObj,DataandWordDocumentinto the root directory of the.docxpackage. - The attacker sets the content types to
application/octet-streamin[Content_Types].xml. - The attacker copies the
_xmlsignaturesfolder from the signed.docdocument into the.docxpackage. - The attacker renames the signature file in
_xmlsignatures, whose name is a random number, tosig1.xml. - The attacker creates the
_xmlsignatures/origin.sigsand_xmlsignatures/_relsfile forsig1.xml. - The attacker adds the content types for
_xmlsignatures/origin.sigsand_xmlsignatures/sig1.xmlin[Content_Types].xml. - The attacker adds a digital signature relationship to
_rels/.rels.
Because a legacy document signed with a newer Microsoft Office produces an XML signature compatible with OOXML signatures, obtaining an OOXML signature over a legacy document lets the attacker insert the legacy document and its signature into any OOXML document to get a universally valid signature. The victim sees a valid signature of a trusted entity while the attacker chooses the content freely.
Universal Signature Forgery (USF)
This attack needs a valid XML signature of a trusted entity, taken from any other application that uses XML signatures, such as signed ODF documents or SAML authentication tokens. SAML is a standard for logging users into services, and its tokens are XML documents carrying a signature. Neither a trustfully signed document nor a signing oracle is needed here.
- The attacker creates a self-signed OOXML document with arbitrary content. Self-signing is only used so the application automatically creates the correct references and hash values in Package Info.
- The attacker extracts the signature file from the OOXML package.
- The attacker replaces Signed Info, Signature Value and Key Info with a valid XML signature of a trusted entity, for example from a signed ODF document. If the new Signed Info element contains references to internal objects within the XML signature, those must be included too.
- The attacker adds the manipulated signature file back to the OOXML package.
Figure 6 shows the attacker placing trustfully signed XML content and referencing it in Signed Info, so only that content is verified and the integrity check of all files in the package is skipped.
When the document opens, the application checks the stored digest values in Package Info against the existing files. Since those match the attacker's content, the check passes. Since Signed Info comes from a valid XML signature of a trusted entity, that check passes too, and the trusted entity in Key Info is shown as the signer.
Malicious Repair Attack (MRA)
Only the relationships that existed at signing time are signed, so more relationships can be added while keeping the signature valid. That produces documents containing signed but not rendered files.
Duplicate Document Attack (DDA)
The attacker obtains a validly signed OOXML document and prepares a new OOXML document to be shown instead. All files in the new document are renamed so they do not collide with the default names. The attacker adds the files of the new package to the signed document, inserts the corresponding references into [Content_Types].xml, and adds a new relationship pointing at the new document.xml. This is allowed because the relationship file is only partially signed. The attacker copies document.xml.rels from their own document and renames it so the relationship file name matches the renamed document.xml.
Evil Type Attack (ETA)
The attacker uses a signed Excel or PowerPoint document to inject the contents of a Word package. They obtain a validly signed Excel or PowerPoint document, create a Word document with freely chosen content, copy the Word-related files into the signed document, copy the content types of those Word files into [Content_Types].xml, insert the references of the Word package files into the relationship file of the signed document, and change the file extension to .docx.
When the victim opens it, Microsoft Office offers to repair the file because of the duplicate file structure, creates a new temporary document, and shows only the attacker's content, while the signature check is performed over the original content, so a valid signature of a trusted entity is displayed. There is a limitation: if the victim saves the repaired document, only the attacker's content is saved while the signature still covers the original content, so the signature is invalid when the file is reopened.
Why it works
Three issues underlie the attacks that work purely within the standard. First, OOXML uses partial signatures: relationship files are only partially signed, [Content_Types].xml is not signed at all, and only strings indexed by IDs are protected, so new files and references can be added after signing. Second, the rendering flow does not distinguish signed from unsigned content, and the standard does not forbid placing the body element in files other than document.xml. Third, the cryptographic verification is complex, with references to multiple elements and files, transformations, hash computations and public-key operations, and the signature verification adds another layer of references to the hash tree of XML signatures.
USF is an implementation flaw in the verification logic: the application does not check that the files in the package are actually referenced in Signed Info, so a valid XML signature from any source gives a universally usable signature that provides no integrity protection over the package. MRA abuses the repair feature and the fact that only relationships present at signing time are signed. On macOS, no signature validation is performed at all.
What it means for users
All tested Office versions are vulnerable. On Windows, every tested Microsoft Office version is vulnerable to each attack, with the signature shown as valid and trusted in combination (1. a) for USF and (1. b) for the others; the repair attacks are limited because they need the victim to accept the repair prompt. CIA and CMA overlay the original content, with the CTRL+A / CTRL+C limitation; LWA shows the attacker's content while the original signed content is not visible. USF gives the attacker complete control of the content with no sign of tampering and shows the original issuer of the XML signature as the signer. Repair attacks need the victim to accept the repair prompt and are limited because saving invalidates the signature.
On macOS the result is worse: the UI layer 1 banner says the document is protected by a signature, an icon with the tooltip "This document contains signatures." is shown, and the document is locked for editing and read-only, but direct changes to document.xml are not detected and the hints stay identical. Removing all content from sig1.xml still shows the same indication, so manipulation is trivial and needs no special attack vectors. Further UI layers showing the signer or signing date do not exist on macOS.
Figure 7 shows the macOS UI layer 1 stating the document is protected by a signature even when the signature file has no content.
OnlyOffice Desktop is fully vulnerable to CIA, LWA and the repair attacks. For CIA, the malicious people.xml is defined as a second main document in _rels/.rels with Id0; because of the lower ID compared with document.xml, OnlyOffice picks people.xml as the main document, so only its content is shown and the originally signed content is hidden. This exploits both the standard's partial signatures and an OnlyOffice implementation flaw that allows two correctly referenced main documents. OnlyOffice does not support embedded fonts, so FIA does not apply; SIA can hide existing content but cannot inject new content, so it is only limited vulnerable. USF fails because OnlyOffice checks that Signed Info contains a reference to Package Info. Repair attacks work without a prompt and the signature stays valid for both variants. OnlyOffice does not support graphics reloaded dynamically via URL.
A separate finding applies to signed OOXML documents in Microsoft Office: graphics added as external resources through a URL are automatically reloaded on opening, and only the URL is signed, so replacing the graphic stored at that URL changes the displayed image while the signature stays valid.
What the researchers suggest
The authors propose one specific mitigation for each attack class, aimed at its root cause. During coordinated disclosure, the vulnerabilities were reported to Microsoft, OnlyOffice and the responsible standardisation committee ISO/IEC JTC 1/SC 34. Microsoft acknowledged the vulnerabilities and awarded the research with a bug bounty, but decided they do not require immediate attention and did not rule out a fix in the future. No feedback was received from OnlyOffice as of October 4th, 2022. Proof of concept files for all attacks are available at https://github.com/RUB-NDS/OOXML_Signature_Security.
Variants to test
- A positive result is the injected content rendering while the signature still shows as valid.
- Prepare a document whose text refers to fonts or styles, strip the references to
fontTable.xmlorstyle.xmlbefore signing, then restore them afterwards. A positive result is the appearance changing after signing without invalidating the signature. - Build custom fonts with removed or swapped glyphs under a name distinct from system fonts, sign without the font reference, then reinsert it. A positive result is hidden or altered text with a valid signature.
- Sign a legacy
.docafter changing the0x01byte beforeCompObjto a printable character, then transplant_xmlsignaturesinto an arbitrary.docxassig1.xmlwith the required content types and relationship. A positive result is the attacker's content shown under the trusted signature. - Replace Signed Info, Signature Value and Key Info in a self-signed OOXML package with a valid XML signature from an ODF document or SAML token. A positive result is the document displaying as validly signed by the original issuer.
- Add a second main document with a lower ID in
_rels/.relsalongsidedocument.xml. A positive result on an implementation that picks the lower ID is the second document being rendered while the signature stays valid. - Inject a Word package into a signed Excel or PowerPoint package and rename the extension to
.docx. A positive result is a repair prompt followed by the attacker's content under the original valid signature. - On macOS, edit
document.xmldirectly or emptysig1.xml. A positive result is the signature banner remaining unchanged.
Glossary
- OOXML (Office Open XML): the file format Microsoft Office uses since 2007; a document is a zip archive containing several XML files.
- XML: a text format that labels data with tags in angle brackets, such as
<name>value</name>. - Zip archive: a single file that contains a folder tree of other files, compressed.
- Digital signature: a mathematical stamp that proves who signed a document and that its contents have not changed since.
- Hash / digest: a short fingerprint computed from a file's contents; any change to the file changes the fingerprint.
- Certificate: a digital identity document, issued by an authority, that binds a public key to a person or organisation.
- Public key / private key: a pair of cryptographic keys; the private key signs, the public key verifies.
- PKI (Public Key Infrastructure): the system of certificates and authorities used to decide whether a key can be trusted.
- Windows Certificate Store: the operating system's built-in list of trusted certificates, which Office uses on Windows.
- Relationship file: a map inside an OOXML package that says which inner files exist and where they are.
- Content type: a label saying what kind of data a file holds, such as text or an image.
- Rendering: the process of turning a document's files into what you see on screen.
- Partial signature: a signature that covers only some of the files in a package, not all of them.
- UI layer: one of the levels of messages Office shows about a signature, from the opening banner to the signer details.
- Attacker model: a description of what an attacker can and cannot do, used to judge whether an attack is realistic.
- Signing oracle: a situation where an attacker can get a trusted party to sign content the attacker chooses.
- Chosen-message attack: a cryptographic attack where the attacker can ask for signatures on messages of their choosing.
- Virtual machine (VM): a computer simulated inside another computer, used to run clean test systems.
- Proof of concept (PoC): a working example that demonstrates a vulnerability.
- Attack vector: one specific way of carrying out an attack.
- Key Confusion: an attack that supplies two keys, one to pass the signature check and another to pass the trust check.
- XML Signature Wrapping (XSW): rearranging XML so the verifier checks one element while the application uses another.
- Signature Exclusion: removing parts of a signature to see whether the verifier gets confused.
- Certificate Faking: using an untrusted key and hoping the trust check is skipped.
- Node Splitting: inserting a comment or entity so different parts of a program read the same value differently.
- HMAC: a keyed hash used for integrity; the paper notes it is not supported for OOXML signatures.
- Font embedding: storing a font file inside the document so it looks the same on any computer.
- FontForge: a free program for creating and editing fonts.
- Hex editor: a tool for viewing and editing the raw bytes of a file.
- Compound File Binary format: the older container format used by
.docfiles. - ODF (OpenDocument Format): a competing office document format that also supports XML signatures.
- SAML: a standard for logging users into services, whose tokens are signed XML documents.
- Coordinated disclosure: reporting vulnerabilities privately to the vendor and agreeing when to publish.
- Bug bounty: a payment a vendor makes to researchers who report vulnerabilities.
- ISO/IEC JTC 1/SC 34: the standards committee responsible for document formats such as OOXML.