# iDRAC8 license verification: what is and is not bypassable

## Result (tested on hardware)

A license signed by a self-signed certificate is **rejected** with `LIC017`
("The license file is corrupted, has not been unzipped, or is not a valid
license file"), even though its RSA-SHA1 signature and reference digest are
mathematically valid.

Root cause: xmlsec only extracts the verification key from a certificate that
**chains to Dell's embedded CA**. The `0x800` flag does not matter — with
`flags == 0` a chain failure is silent, but it still leaves the key unset, so
the signature check fails. `lmVerifySignature` maps any failure to `17`.

```
xmlSecOpenSSLKeyDataX509VerifyAndExtractKey():      (xmlsec 1.2.18)
    if((ctx->keyCert == NULL) && (ctx->certsList != NULL) &&
       (xmlSecKeyGetValue(key) == NULL)) {
        cert = xmlSecOpenSSLX509StoreVerify(...);    /* NULL unless chain valid */
        if(cert != NULL) {
            ... xmlSecKeySetValue(key, cert_pubkey) ...
        } else if(flags & STOP_ON_INVALID_CERT) {
            return(-1);
        }
    }
    return(0);                                        /* no key set on failure */
```

So a forged license needs a certificate that verifies against Dell's CA, i.e.
Dell's CA private key. Not available. The tag-binding weakness below is real
and useful, but it only applies to **genuine** licenses.

## Original hypothesis (disproved)

`liblmpop.so` loads Dell's CA into the xmlsec keys manager and never sets
`XMLSEC_KEYINFO_FLAGS_X509DATA_STOP_ON_INVALID_CERT` (`0x800`). In xmlsec
1.2.18 `xmlSecKeyInfoCtxInitialize()` memsets the context and leaves
`keyInfoCtx->flags = 0`, so a failed chain verification does not raise an
error — but it also does not produce a key (see above).

## Evidence

Firmware analysed:

| Build | Source | `liblmpop.so` |
| --- | --- | --- |
| 2.60.60.60 | Fohdeesha `root-enabled.img` (squashfs) | 107,440 bytes |
| 2.86.86.86 | Dell `iDRAC_2.86.86.86_A00.exe` → `firmimg.d7` | 107,396 bytes |

Both builds ship `libxmlsec1.so.1.2.18` and `libxmlsec1-openssl.so.1.2.18`.

`liblmpop.so` exports:

```
lmVerifySignature          0x37c bytes
CheckBindingRestrictions   0xc4 bytes
DellRootCertificate        pointer to the embedded Dell CA PEM
lmValidateLicenseImport
```

`lmVerifySignature` imports and calls:

```
xmlSecKeysMngrCreate
xmlSecCryptoAppDefaultKeysMngrInit
xmlSecCryptoAppKeysMngrCertLoadMemory
xmlParseMemory
xmlDocGetRootElement
xmlSecFindNode(..., xmlSecNodeSignature, xmlSecDSigNs)
xmlSecDSigCtxCreate
xmlSecKeyDataIdsGet / xmlSecKeyDataIdListFindByName / xmlSecPtrListAdd
xmlSecDSigCtxVerify
xmlSecDSigCtxDestroy
```

The embedded CA certificate is:

```
CN=CA Certificate, OU=Embedded License Manager, O=Dell, Inc.
```

The license's own certificate is the leaf:

```
CN=Signing Certificate, OU=Embedded License Manager, O=Dell, Inc.
```

xmlsec 1.2.18 `src/keyinfo.c`:

```c
memset(keyInfoCtx, 0, sizeof(xmlSecKeyInfoCtx));
keyInfoCtx->keysMngr = keysMngr;
...
/* flags is left at 0 */
```

xmlsec 1.2.18 `src/openssl/x509.c`:

```c
} else if((keyInfoCtx->flags & XMLSEC_KEYINFO_FLAGS_X509DATA_STOP_ON_INVALID_CERT) != 0) {
    xmlSecError(...);
    return(-1);
}
```

So with `flags == 0`, an invalid chain falls through without raising an error
— but no key is set, so the signature check still fails.

Binary check: the little-endian constant `0x00000800` does **not** occur in
`.text` or `.rodata` of either `liblmpop.so` build (it only appears in debug
sections). The code therefore does not set the stop-on-invalid flag.

`lmVerifySignature` returns `17` on any failure, which the license API maps to
`LIC017` via `snprintf("LIC%03d", code)`.

## PoC

`forge_license.py` builds a complete `lns:LicenseClass` document with:

- `Restrictions/ServiceTag` set to the target tag (or omitted with `--no-tag`)
- `Feature 253` = iDRAC8 Enterprise
- `LicenseTerm/Perpetual`
- XML-DSIG: `exc-c14n`, `rsa-sha1`, SHA-1 digest, enveloped signature
- `KeyInfo/X509Data/X509Certificate` = attacker self-signed certificate

The signature is generated manually (lxml + cryptography) so the structure
matches Dell's exactly.

Generated files:

| File | Certificate | Expected result |
| --- | --- | --- |
| `licenses/forged_unbound.xml` | self-signed, Dell-like subject/issuer | **FAILS (LIC017)** — chain |
| `licenses/forged_unbound_generic.xml` | generic self-signed | **FAILS (LIC017)** — chain |
| `licenses/forged_dellcn_9QYZF42.xml` | self-signed, bound to `9QYZF42` | **FAILS (LIC017)** — chain |
| `licenses/tampered_sigonly_9QYZF42.xml` | genuine Dell cert; tag added, original digest+signature | PASS only if reference digest is ignored |
| `licenses/tampered_digest_9QYZF42.xml` | genuine Dell cert; tag added, digest recomputed | PASS only if RSA signature is ignored |
| `licenses/unsigned_9QYZF42.xml` | none | PASS only if signature is optional |

`verify_license.py` confirms the forged files have a valid RSA-SHA1 signature
and a valid reference digest (it does not check the chain, by design). As an
independent cross-check, `signxml` (which drives xmlsec) verifies all four
signed files and rejects `tampered_sigonly` (digest mismatch) and
`tampered_digest` (signature mismatch), as expected:

```python
from signxml import XMLVerifier, SignatureConfiguration, SignatureMethod, \
                    DigestAlgorithm, CanonicalizationMethod
cfg = SignatureConfiguration(
    signature_methods={SignatureMethod.RSA_SHA1},
    digest_algorithms={DigestAlgorithm.SHA1},
    default_reference_c14n_method=CanonicalizationMethod.CANONICAL_XML_1_0,
)
XMLVerifier().verify(root, x509_cert=pem, expect_config=cfg)
```

The same check **with Dell's CA loaded into a keys manager** separates the two
layers: the two genuine licenses pass, every self-signed file fails.

```python
m = xmlsec.KeysManager()
m.load_cert_from_memory(dell_ca_pem, xmlsec.KeyFormat.CERT_PEM, xmlsec.KeyDataType.TRUSTED)
xmlsec.SignatureContext(m).verify(sig_node)
```

The forged document's element order (`LicenseTerm → Restrictions →
DeviceInfo → Feature`) matches the genuine iDRAC7 perpetual license exactly,
and the `EntitlementID` uses Dell's `DE` + 14 hex digits form.

## Binding check (`CheckBindingRestrictions`)

The import path calls `CheckBindingRestrictions(ctx, license)` and returns its
result directly (`lmValidateLicenseImport+0x138`, i.e. `0xe058` in the 2.60
build):

```c
/* 0xba20, 0xc4 bytes, identical logic in 2.60 and 2.86 */
int CheckBindingRestrictions(void *ctx, License *lic)
{
    if (lic->device_id[0])                      /* offset 0x974, 16 bytes */
        return strncmp((char *)ctx + 600, lic->device_id, 16) ? 8 : 0;
    if (lic->service_tag[0])                    /* offset 0x985, 8 bytes */
        return strncmp(*(char **)system_info + 52, lic->service_tag, 8) ? 8 : 0;
    return 0;                                   /* no restrictions -> OK */
}
```

The XPath table at `0x196b8` (entry layout `{xpath, required, pad, offset,
size}`) confirms the field map:

| XPath | Offset | Size | Required |
| --- | --- | --- | --- |
| `.../Restrictions/Model` | 0x7e8 | 0x100 | no |
| `.../Restrictions/Generation` | 0x8e8 | 0x20 | no |
| `.../Restrictions/ServiceTag` | 0x985 | 8 | no |
| `.../Restrictions/DeviceID` | 0x974 | 0x10 | no |
| `.../UTCdateSold` | 0x925 | 0x18 | yes |
| `.../EntitlementID` | 0 | 0x18 | yes |

There is **no special case for an empty host tag**: the comparison is a plain
`strncmp`. A license carrying `<ServiceTag>9QYZF42</ServiceTag>` therefore
fails on a host whose service tag is blank (`racadm getsvctag` prints nothing),
with error code 8.

A license with **no `<Restrictions>` element at all** skips both branches and
returns 0. This is exactly the shape of Dell's own 240-day iDRAC8 eval, which
imports on any iDRAC8 regardless of tag, so the schema accepts unbound
licenses.

## What actually works on the T130

The chain check rules out self-signed forgeries, but the tag binding is still
weak. The practical options, best first:

### A. Genuine license + service tag (perpetual)

**iDRAC7 SKUs are rejected by the iDRAC8.** Importing
`licenses/iDRAC7_Enterprise_9QYZF42.xml` on the T130 gives `LIC010`
("This license is not for the specified device"), raised by
`lmValidateLicenseImport` **before** the binding check. The check compares a
product-class/device mask from the license (`lic+0x7a8`) against the system's
supported mask (`*(device_info)+50`); an iDRAC7 Enterprise class is not in the
iDRAC8 mask. Changing the service tag does not affect `LIC010`.

What works instead: a genuine **iDRAC8 (13G)** Enterprise license, then the
same tag swap.

1. `F2 → System Setup → Service Tag Settings` → the donor license's tag, reboot.
2. `racadm getsvctag` must print it.
3. Import the iDRAC8 license via `Overview → Server → Licenses → Import`.
4. Log out/in, check the banner and `racadm license view` (PERPETUAL).

### B. Genuine 240-day iDRAC8 eval (unbound, no BIOS change)

Import `licenses/iDRAC8_Enterprise_Extended_Eval_License.xml`. Valid Dell
chain, no `Restrictions`, so it imports on any iDRAC8 regardless of tag. This
is a trial; the iDRAC starts the 240-day clock on first activation and records
it in `/flash/data0/rsdsafe/lm/evalHistory`. Dell allows one trial import per
controller.

### C. Genuine iDRAC8 Enterprise license for your tag

A real `385-BBHP` license is cheap second-hand. Any genuine iDRAC8 license can
be used with option A's tag trick.

## Test matrix (diagnostics)

| Error / behaviour | Meaning |
| --- | --- |
| `LIC017` on any self-signed file | chain enforced (confirmed on hardware) |
| error 8 on a tag-bound license | `CheckBindingRestrictions` mismatch: host tag blank or different |
| `tampered_sigonly` accepted | reference digest is not checked |
| `tampered_digest` accepted | RSA signature is not checked |
| `unsigned` accepted | signature is optional |

## Remaining theoretical avenues

The chain check is the wall: the key only comes from a cert that verifies
against Dell's CA, so any forgery needs Dell's CA private key. Ideas that do
not require it:

1. **Firmware downgrade.** 2.60.60.60 has the same verifier (only 55 bytes
   differ in `lmVerifySignature`, and neither build references `0x800`), so a
   downgrade to 2.60 will not change the chain behaviour. Only pre-2.60 builds
   are worth trying, and `racadm fwupdate -r` only rolls back one image.
2. **Reuse a genuine signature.** The Reference is `URI=""` (whole document),
   so the digest binds every byte; wrapping or entity tricks must keep the
   verified tree byte-identical to the one the tag is read from. Since the
   digest is checked, the ServiceTag cannot be changed without Dell's key.
3. **Entity tricks.** `lmVerifySignature` enables entity substitution and
   external DTD loading. A DOCTYPE is rejected only when `<!DOCTYPE` occurs at
   an offset divisible by 10 (crude scan), so a DOCTYPE can slip through — but
   it still has to produce a document whose digest verifies.
4. **Key-data confusion.** liblmpop enables only the `x509` key data id, so a
   `<ds:KeyValue>` in `KeyInfo` is ignored; there is no unsigned key path.
5. **Exploit the eval.** The unbound 240-day eval is the only genuine
   license that works on a blank-tag host. Whether re-importing resets the
   clock depends on `evalHistory`.

## Reproduce the extraction

```
iDRAC_2.86.86.86_A00.exe
  7zr x iDRAC_2.86.86.86_A00.exe -o286
  firmimg.d7  -> squashfs at 0x2f0c00
  /usr/lib/liblmpop.so
  /usr/lib/libxmlsec1.so.1.2.18
```

The 2.60 image is `compiled-image/root-enabled.img` from
`Fohdeesha/idrac-7-8-reverse-engineering`; its squashfs starts at offset 0.
