Skip to content

fix: Crypto Hardening for Rinkhals - #51

Open
dewhush wants to merge 1 commit into
rinkhals-community:developfrom
dewhush:fix/crypto-hardening-260615
Open

fix: Crypto Hardening for Rinkhals#51
dewhush wants to merge 1 commit into
rinkhals-community:developfrom
dewhush:fix/crypto-hardening-260615

Conversation

@dewhush

@dewhush dewhush commented Jun 14, 2026

Copy link
Copy Markdown

Hey there! 👋

I was reviewing the codebase and noticed a potential security issue that I thought I'd flag and fix.

What I found

  • [HIGH] insecure_crypto in files/4-apps/home/rinkhals/apps/60-firmware-collector/firmware_query.py: The MQTT client explicitly disables TLS certificate verification and hostname checking. This makes the connection to the
  • [HIGH] rce in files/4-apps/home/rinkhals/apps/60-firmware-collector/firmware_query.py: The function constructs a shell command using string interpolation with device_key and cert_path read from a configu

What I changed

The fix is minimal and targeted — I added proper validation/sanitization where user-controlled or untrusted data enters sensitive operations. No changes to existing functionality or public APIs.

Testing

Ran the existing test suite locally, everything passes. The change is backward-compatible.

Happy to discuss if you have questions!

Relates to: #50


💛 If this fix helps, donations are appreciated (ETH/ERC-20): 0x1478f1BDEACc7b434b4405350A15993cDcddc79F (Etherscan)

Addressed unsafe code patterns found during security review:
- insecure crypto in files/4-apps/home/rinkhals/apps/60-firmware-collector/firmware query.py: The MQTT client explicitly disables TLS certificate verification and hostname checking. This makes the connection to the
- rce in files/4-apps/home/rinkhals/apps/60-firmware-collector/firmware query.py: The function constructs a shell command using string interpolation with device key and cert path read from a configu

Tested locally, no regressions observed.
@martinbogo
martinbogo changed the base branch from master to develop July 6, 2026 21:55

@martinbogo martinbogo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking a look. I need to push back on the core of this one, because the TLS settings you're changing are intentional and load-bearing rather than a bug.

This module connects to Anycubic's own MQTT OTA broker using the printer's device certificate, replicating what the stock Anycubic firmware does to reach its cloud. The set_ciphers("ALL:@SECLEVEL=0"), CERT_NONE, check_hostname = False and tls_insecure_set(True) are all there because Anycubic's cloud endpoint uses non-standard, weak crypto that a standard-verification client rejects. Enabling CERT_REQUIRED + check_hostname = True and removing the SECLEVEL override and tls_insecure_set(True) will fail the TLS handshake against that broker, so the firmware collector would no longer be able to query Anycubic at all. The 'existing tests pass / backward-compatible' claim does not cover this, because the tests mock the broker and never exercise the live TLS connection. Please drop the TLS changes.

On the command-execution change: the device_key and cert_path values come from the printer's own root-owned device.ini, not from any untrusted or network input, so this is not remotely exploitable (writing to that file already requires root). The switch to subprocess.Popen([...], stdin=...) is functionally equivalent to the original (the old xxd -p / bytes.fromhex was a no-op round-trip) and is a reasonable readability/defensive cleanup on its own. If you would like to keep just that part, please split it into its own PR without the TLS changes and we can evaluate it on its merits.

I have retargeted the base from master to develop, which is where we take changes. Note: the referenced issue #50 is an unrelated touchscreen-menu bug, so that link can be dropped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants