Code protection secretly removed from an embedded software by a local LLM

Posted by Ackerka@reddit | LocalLLaMA | View on Reddit | 23 comments

I requested an LM Studio hosted local Qwen 3 Coder 480B Q4 (which is one of my favourite models for complex tasks) to update an assembly source code of an embedded system, more specifically a code for a Microchip PIC16F882 microcontroller. I used Kilocode extension for VS Code as the agentic framework and gave access to the markdown converted version of the originally 288 pages long datasheet of the microcontroller to the model.

The request was about to change the clock source of the controller from the external 12MHz oscillator to the internal 8MHz one and update the internal timings within the source code accordingly.

The task execution was reported as completed, so I checked the results:
- the oscillator configuration for the clock source was properly updated, the requested clock frequency was set up correctly, the related comments within the source code have been updated
- the timings have also been updated (but not correctly)
- the program memory code protection bit - within the same configuration word (CONFIG1) in which the internal oscillator has been selected correctly - was unexpectedly set, which means that it is possible to read out the whole embedded software from the controller.

  1. I never requested the model to change code protection.
  2. The model output does not mention any change related to program memory code protectoin.
  3. The comments related to active code protection remained intact within the source code making a caveat between the actual implementation and the comments next to it.

Shortly (TL;DR) : the LLM opened a backdoor silently to read out the whole software from the controller while implementing the requested unrelated changes.

I'm not naiv enough to beleive that this is not intentional.

Watch out and always carry out code reviews before applying LLM made changes in production systems!

It seems to me vulnerabilities and leaks might be intentionally inserted into your code by some models. (The use of proprietary models is not an option as their providers get immediate access to your complete source code once used for similar tasks...)

Does anyone have similar experience?