Skip to content

[Bug] cdrm mode: false startup warning and decryption failures due to incorrect header serialization #624

@ne0lith

Description

@ne0lith

Describe the bug

Two separate bugs affecting cdrm key mode, both present in version 3.14.7.

Bug 1: A false "CDM return an error" warning is shown on every startup even when cdrm-project.com is fully operational.

Bug 2: All cdrm decryption requests fail silently due to incorrect header serialization, resulting in 0 downloads for DRM-protected content.


To Reproduce

  1. Set key-mode-default to cdrm in config
  2. Run ofscraper --action download --posts messages --username <user>
  3. Observe red "CDM return an error" warning on startup despite service being up
  4. Observe 0 downloads for DRM-protected content despite media being found

Expected behavior

  • Startup check should correctly report cdrm-project.com as available when it is up
  • DRM-protected content should decrypt and download successfully

Screenshots/Logs

N/A, both bugs are reproducible from source code inspection alone (see Additional Context)


Config

"cdm_options": {
    "private-key": null,
    "client-id": null,
    "key-mode-default": "cdrm"
}

System Info

  • OS: Windows 11
  • Version: 3.14.7
  • Installed via: uv

Additional context

Bug 1: ofscraper/utils/system/network.py line ~33 performs a GET request
to /api/decrypt, which only accepts POST, so it always returns non-200
and incorrectly triggers the red warning.

Fix:

# Before
with c.requests(url=url, headers={}) as r:

# After
# this is a bandaid, obviously
with c.requests(url="https://cdrm-project.com", headers={}) as r:

Bug 2: ofscraper/commands/scraper/actions/download/utils/keyhelpers.py
line ~121 serializes headers with json.dumps(), producing double-quoted JSON.
cdrm-project.com parses this field with Python's ast.literal_eval, which
requires single-quoted Python dict syntax, causing all decryption requests
to fail with "An error occurred getting headers".

Bandaid fix (restores functionality with cdrm-project.com):

# Before
"headers": json.dumps(headers),

# After
"headers": str(headers),

Note: str() is not a general solution and may break other endpoints.
The proper fix should handle serialization per-endpoint, since other CDM
services may expect standard JSON. The root issue is that cdrm-project.com
uses ast.literal_eval instead of standard JSON parsing for the headers field.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions