Skip to content
Blog

The parts of a KNX product file nobody signed

Florian Mathieu
, 4 min read, filed under knx, security, ets

Tech stack
  • .NET
  • C#
  • ETS
  • KNX

KNX product files (.knxprod) describe what a device is and how to program it: its parameters, its memory layout, and the scripts that calculate values. Manufacturers sign them, and ETS, the official KNX tool, checks the signature before it imports a file. That check is what’s supposed to stop anyone from handing an installer a modified product file.

I wrote my own implementation of that verification. It worked on almost every file, except for a few perfectly legitimate ones from a real manufacturer, which it marked as failing the integrity check. ETS accepted those same files without complaint. So either my implementation was wrong, or ETS was.

It turned out to be ETS.

How the hash is built

ETS doesn’t hash a product file’s raw bytes. It walks the XML, picks out the elements that are relevant for registration, and serializes them into a stream of “bytes to hash”. That stream is what the application hash is computed over, and what the signature ultimately commits to. Anything that isn’t in the stream isn’t protected.

I’m honestly not a fan of this custom serializer. For each value it writes a type and the value itself, but no length, so nothing in the stream marks where one value ends and the next begins. That has two consequences:

  • It can’t be decoded. There’s no reliable way to turn the bytes back into the XML they came from. When you’re debugging a hash mismatch, or testing your own implementation against ETS, you’re left comparing opaque blobs instead of seeing which element differs.
  • It’s ambiguous. Two different files could serialize to exactly the same bytes, and therefore the same hash, while containing different elements. That wouldn’t take a cryptographic collision, just an ambiguous encoding. I haven’t tried to build such a pair, but I wouldn’t be surprised if it’s possible.

Both would have been avoided by writing a length before every variable-length value. It’s a small change that makes the format unambiguous, decodable, and far easier to analyse and test.

The code that builds this stream lives in Knx.Ets.XmlSigning.dll, a .NET assembly that ships with ETS. I decompiled it to see what it does. In SignAndHashUtils.cs, the method GetHashBytesOfCurrentNode handles elements whose value is their text content, such as a <Script> holding JavaScript or a <Data> holding base64:

if (info is InnerTextElementInfo)
{
    while (this._reader.NodeType != XmlNodeType.Text && this._reader.NodeType != XmlNodeType.CDATA && this._reader.Read())
    {
    }
    ((InnerTextElementInfo)info).WriteValue(this._reader.Value, binaryWriter);
}

The loop moves the XmlReader forward until it lands on the element’s text, then hashes that text.

The bug

That works as long as the element has text. If it’s empty, written as <Script /> or <Script></Script>, there’s no text node inside it. The loop doesn’t stop at the end of the element: it keeps calling Read() until it finds a text node anywhere further in the document, and it walks straight past the sibling elements in between. It then hashes that later text as if it belonged to the empty element.

When the method returns, the caller carries on iterating over the children of the parent element, but the reader is no longer where it thinks it is. The elements it skipped never make it into the bytes to hash.

These are the elements handled this way, and so the ones that trigger the bug when they’re empty:

Element Handled as
Script InnerTextStringElementInfo
Data InnerTextBase64ElementInfo
Mask InnerTextBase64ElementInfo
Offset InnerTextUInt32ElementInfo
LRTransformation InnerTextStringElementInfo
RLTransformation InnerTextStringElementInfo

This isn’t a theoretical input. The file that put me on to it, MDT’s MDT_KP_SCN_03_IP_Interface_Secure_V21a.knxprod, is a genuine product file that contains an empty <Script />. My verifier hashed the elements after it; ETS didn’t. That’s why the two disagreed.

Why it matters

The point of signing a product file is that every part that affects the device is fixed by the manufacturer. With this bug, the elements that follow an empty text element are left out of the hash, so they’re potentially not covered by any signature. An attacker could then change, corrupt or replace them, and ETS would still accept the file as legitimate.

How far that goes depends on which elements end up being skipped in a given file, and I haven’t mapped the full impact. But a product file is exactly the kind of thing that gets passed around between manufacturers, integrators and installers, and its signature is the only thing that says it hasn’t been touched along the way.

The fix

The loop needs to stop at the end of the element, and an empty element should hash as an empty value:

if (info is InnerTextElementInfo)
{
    // Only read inner content if the element isn't self-closing
    if (!this._reader.IsEmptyElement)
    {
        while (this._reader.NodeType != XmlNodeType.Text &&
               this._reader.NodeType != XmlNodeType.CDATA &&
               this._reader.NodeType != XmlNodeType.EndElement &&
               this._reader.Read())
        {
        }
    }

    // Hash an empty string if there's no text
    string value = (this._reader.NodeType == XmlNodeType.Text ||
                    this._reader.NodeType == XmlNodeType.CDATA)
                   ? this._reader.Value : "";
    ((InnerTextElementInfo)info).WriteValue(value, binaryWriter);
}

Changing how the bytes to hash are generated changes the resulting hashes, so files signed with the old behaviour would need handling too. That’s a decision for the KNX Association, not something a patch can settle.

Two more things worth a look

While I was in this code, two other choices stood out. I didn’t explore them further, but they deserve attention:

  • MD5. MD5 is used to commit to data that should be tamper resistant. MD5 collisions can be generated on any modern computer with freely available tools, so it shouldn’t be used for that.
  • SHA-1. The HardwareSigner verifies an RSA signature over a SHA-1 hash. SHA-1 is broken against collision attacks: if someone can produce a malicious file with the same SHA-1 hash as a legitimate one, the legitimate RSA signature verifies for the malicious file too.

Disclosure

I reported this to the KNX Association on 20 April 2026, together with the MDT file that triggers it, and gave the industry-standard 90-day disclosure deadline, so the earliest date for publication was 19 July 2026.

What this shows

None of this needed access to anything secret. It came from implementing a check independently and taking it seriously when the result disagreed with the official tool. That’s one of the quieter benefits of open implementations of a standard: a second implementation is also a second opinion.