Jonathan Birch<p>When giving <a href="https://infosec.exchange/tags/security" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>security</span></a> guidance to developers, be sure to impart an understanding of the underlying problem, not just which API's to use or not. If you don't do this, enterprising developers will often reintroduce the problem by adding the problematic capabilities to an otherwise safe API.</p><p>To give a specific example, and to try to atone for some of my past sins:</p><p>The underlying problem in unsafe deserialization that leads to remote code execution is user-provided data telling your application what type it wants to be. When data can choose what type it is, it can choose types that have exploitable side effects in their constructors, setters, or destructors. Polymorphic deserializers are inherently unsafe.</p><p>In the past I've told people "use this API, it's safe". But when that API is safe because it doesn't allow polymorphism, developers inevitably modify the API to add polymorphism when it makes the overall design of the application simpler.</p><p>The portion of the <a href="https://infosec.exchange/tags/OWASP" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>OWASP</span></a> <a href="https://infosec.exchange/tags/serialization" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>serialization</span></a> cheat-sheet on .NET is based on a talk I gave in 2017 before I understood this problem. (<a href="https://cheatsheetseries.owasp.org/cheatsheets/Deserialization_Cheat_Sheet.html#net-csharp" rel="nofollow noopener" translate="no" target="_blank"><span class="invisible">https://</span><span class="ellipsis">cheatsheetseries.owasp.org/che</span><span class="invisible">atsheets/Deserialization_Cheat_Sheet.html#net-csharp</span></a> )</p><p>It's much more difficult, but training developers to write secure code requires teaching them what the real problems are.</p><p><a href="https://infosec.exchange/tags/appsec" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>appsec</span></a> <a href="https://infosec.exchange/tags/training" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>training</span></a></p>