> For the complete documentation index, see [llms.txt](https://scriptingxss.gitbook.io/embedded-appsec-best-practices/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://scriptingxss.gitbook.io/embedded-appsec-best-practices/7_usage_of_debugging_code_and_interfaces.md).

# Usage of Debugging Code and Interfaces

It is important to ensure all unnecessary pre-production build code, as well as dead and unused code, has been removed prior to firmware release to all market segments. This includes but is not limited to potential backdoor code and root privilege accounts that may have been left by parties such as Original Design Manufacturers (ODM) and Third-Party contractors. Typically this falls in scope for Original Equipment Manufacturers (OEM) to perform via contracts or reverse engineering of binaries. This should also require ODMs to sign Master Service Agreements (MSA) insuring that either no backdoor code is included and that all code has been reviewed for software security vulnerabilities holding all Third-Party developers accountable for devices that are mass deployed into the market.

**Considerations (Disclaimer: The List below is non-exhaustive):**

* Remove backdoor accounts used for debugging, deployment verification and/or customer support purposes.
* Ensure development, diagnostic, or debug features are not included within release builds.
* Perform code clean up sessions to ensure dead or unused code is removed across repositories&#x20;
* Ensure third party libraries and binary images are reviewed for backdoors by staff before market deployment.
  * Tools such as Binwalk, Firmadyne, IDA pro, radare2, Firmware Mod Toolkit (FMK), Firmware Analysis Comparison Toolkit (FACT), and various other tools listed in the additional references (#4) should be utilized for firmware analysis.

## Additional References <a href="#additional-references" id="additional-references"></a>

* <https://www.owasp.org/index.php/Leftover_Debug_Code>
* <https://cwe.mitre.org/data/definitions/489.html>
* <http://www.kb.cert.org/vuls/id/419568>
* [Firmware and binary analysis tool index](https://scriptingxss.gitbook.io/firmware-security-testing-methodology/#firmware-and-binary-analysis-tool-index)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://scriptingxss.gitbook.io/embedded-appsec-best-practices/7_usage_of_debugging_code_and_interfaces.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
