Canva Affinity EMF File EMR_FRAMERGN Type Confusion Vulnerability
A crafted EMF file can make the EMR_FRAMERGN record reference a brush index that does not match the brush created by EMR_CREATEBRUSHINDIRECT, so the loader treats an unrelated object as a brush. This type confusion leads to memory corruption and could allow arbitrary code execution.
A type confusion vulnerability exists in the EMF functionality of Canva Affinity. A specially crafted EMF file can trigger this vulnerability, which can lead to memory corruption and result in arbitrary code execution.
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.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The EMF loader uses the ihBrush index from EMR_FRAMERGN to fetch an object from the object table without verifying that the entry is actually a brush created by EMR_CREATEBRUSHINDIRECT.
Impact
Depending on the memory layout of the process, this could give arbitrary read and write access and ultimately arbitrary code execution, though the demonstrated result is a crash from an uninitialised pointer.
What the attacker needed
Victim opens a crafted EMF file; local user interaction
The fix
The vendor released a patch, and the loader should validate that the indexed object table entry is a genuine brush before using it.
How it was found
- Create an EMF file whose EMR_CREATEBRUSHINDIRECT record stores the brush at one index.
- In the EMR_FRAMERGN record, set ihBrush to a different index that holds an unrelated object.
- Open the file in the affected application and observe the object lookup during loading.
- Watch the unrelated object be used as a brush, reading an uninitialised field as a pointer and crashing.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
EMF is a file format for storing pictures. Inside it, small records describe things like brushes used to draw borders, and each brush is stored in a numbered table. The program trusted a number in one record without checking it pointed at a real brush, so it picked up a different object and later used it as if it were a brush, which crashed the program and could let an attacker run their own code.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.