<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Devs Daddy</title>
    <description>The latest articles on Forem by Devs Daddy (@devsdaddy).</description>
    <link>https://forem.com/devsdaddy</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1403472%2F2bd65618-32b2-4139-a698-7a2e75574534.jpeg</url>
      <title>Forem: Devs Daddy</title>
      <link>https://forem.com/devsdaddy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/devsdaddy"/>
    <language>en</language>
    <item>
      <title>Typescript Application Security from A to Z: A Guide to Protecting Against Obvious and Not-So-Obvious Vulnerabilities</title>
      <dc:creator>Devs Daddy</dc:creator>
      <pubDate>Wed, 29 Apr 2026 12:36:47 +0000</pubDate>
      <link>https://forem.com/devsdaddy/typescript-application-security-from-a-to-z-a-guide-to-protecting-against-obvious-and-55nh</link>
      <guid>https://forem.com/devsdaddy/typescript-application-security-from-a-to-z-a-guide-to-protecting-against-obvious-and-55nh</guid>
      <description>&lt;p&gt;I often notice how careless &lt;strong&gt;some developers are about the security of their applications&lt;/strong&gt;. They only begin to think about protection methods when they have to rewrite a large portion of the application. &lt;em&gt;Today, we'll cover classic and other attack methods, examine where the compiler falls short, and build modern protection based on best practices and specific code examples.&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This article specifically &lt;strong&gt;provides simplified attack methods and vulnerability examples&lt;/strong&gt; to make it easier to understand the mechanics.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;TypeScript&lt;/strong&gt; has undoubtedly become one of the leaders in web development. It's used to build powerful React applications and complex microservices on Nest or Fastify. Developers often value type safety, but this isn't classic security, as a string in TypeScript is still just a string, potentially vulnerable to SQL injection and XSS vulnerabilities. The compiler doesn't check business logic, doesn't filter input data, and doesn't detect that you've shared a JWT secret in a public repository.&lt;/p&gt;

&lt;p&gt;I built this article around &lt;strong&gt;a simple principle&lt;/strong&gt;: types are not a defense, but a tool of discipline. We'll examine attacks and defenses on two key platforms:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Backend (Node.js, Express/Fastify/NestJS):&lt;/strong&gt; injections, prototype pollution, unsafe deserialization, data leaks through errors.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Frontend (React, Next.js, Angular):&lt;/strong&gt; XSS, CSRF, prototype poisoning through dependencies, sensitive data leaks, SSR attacks.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In each section, I've provided real code examples, a simple explanation of the vulnerability, and mitigation methods. So, a fascinating journey into the world of application security awaits us.&lt;/p&gt;




&lt;h2&gt;
  
  
  Backend: When a request arrives before type checking
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;TypeScript&lt;/strong&gt; on the server enforces contracts between layers, but the entry point, an &lt;strong&gt;HTTP request, is always raw data&lt;/strong&gt;. Even if you use &lt;strong&gt;NestJS with decorators&lt;/strong&gt; like &lt;code&gt;@Body()&lt;/code&gt;, validation may be absent or incomplete.&lt;/p&gt;

&lt;h3&gt;
  
  
  Case 1: SQL injection via TypeORM (yes, it's possible)
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8v7v9gv31aj0p30q8hed.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8v7v9gv31aj0p30q8hed.png" alt="What is SQL Injections" width="800" height="276"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Many people think that ORMs completely protect against injection attacks. But when a developer resorts to raw queries or tricky operators, TypeScript won't save them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Vulnerable Code (Basic Case Study with Raw Data):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;getConnection&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;typeorm&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/users&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;sortColumn&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;order&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;query&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="c1"&gt;// We wait for sortColumn = "name", order = "ASC"&lt;/span&gt;
  &lt;span class="c1"&gt;// But call raw query&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;users&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;getConnection&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;query&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s2"&gt;`SELECT * FROM users ORDER BY &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;sortColumn&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;order&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, the parameters are directly substituted into SQL. &lt;strong&gt;The attacker sends:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="err"&gt;GET /users?sortColumn=name&amp;amp;order=ASC; DROP TABLE users; --
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;TypeScript sees &lt;code&gt;sortColumn: string&lt;/code&gt;, and everything looks fine from its perspective. But the relational database receives two queries.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt; Validate allowed values ​​and use parameterized queries or an API that doesn't allow concatenation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;IsIn&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;IsString&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;class-validator&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;validateOrReject&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;class-validator&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;UsersQueryDto&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;IsIn&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;name&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;email&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;createdAt&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
  &lt;span class="nx"&gt;sortColumn&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;IsIn&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ASC&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;DESC&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
  &lt;span class="nx"&gt;order&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ASC&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;DESC&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/users&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;dto&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;UsersQueryDto&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;assign&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;dto&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;query&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;validateOrReject&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;dto&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;users&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;userRepository&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;order&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;dto&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;sortColumn&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt; &lt;span class="nx"&gt;dto&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;order&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This way, we guarantee that nothing but the expected columns will end up in the ORDER BY clause.&lt;/p&gt;

&lt;p&gt;It would seem so... &lt;strong&gt;Elijah, what are you talking about? We already use Query Builder, these are obvious things!&lt;/strong&gt; But I've also seen solutions where the developer inserted partially raw queries. &lt;strong&gt;For example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/search&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;q&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;query&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;users&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;userRepository&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;where&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Raw&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;alias&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;alias&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; LIKE '%&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;q&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;%'`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And it turns out that here the search string &lt;code&gt;q&lt;/code&gt; is directly pasted into the SQL expression.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="err"&gt;GET /search?q=%25'%3BDROP%20TABLE%20users%3B--
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And if you still &lt;strong&gt;can't give up Raw SQL code inserts&lt;/strong&gt;, the right solution would be to use parameterized placeholders (supported, for example, in TypeORM):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;where&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Raw&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;alias&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;alias&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; ILIKE :query`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;query&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`%&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;q&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;%`&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Another similarly dangerous pattern is to build a query using &lt;code&gt;createQueryBuilder&lt;/code&gt;, concatenating strings for conditions or sorting.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/users&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;filter&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;query&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// filter = "admin'; DROP TABLE users; --"&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;qb&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;userRepository&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createQueryBuilder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;user&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;qb&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`user.role = '&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;'`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;users&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;qb&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getMany&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;String interpolation within &lt;code&gt;.where()&lt;/code&gt; exposes the same injection opportunities as direct SQL. An attacker gains complete control over the query.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A safer alternative: use QueryBuilder parameters:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;qb&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;user.role = :role&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;filter&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Key lesson:&lt;/strong&gt; Any string concatenation when forming SQL is suspect, even if it is hidden behind ORM methods.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Case 2: NoSQL Injection in MongoDB with Mongoose
&lt;/h2&gt;

&lt;p&gt;Even when using ODM, you can still get an injection if you pass objects directly from a query.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/login&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;username&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;password&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="c1"&gt;// req.body can contain: { username: { $ne: null }, password: { $ne: null } }&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;UserModel&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;findOne&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;username&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;password&lt;/span&gt; &lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="nf"&gt;exec&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;token&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;generateToken&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;401&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the client sends JSON with MongoDB operators (&lt;code&gt;$gt&lt;/code&gt;, &lt;code&gt;$ne&lt;/code&gt;), the query will become &lt;code&gt;{ username: { $ne: null }, password: { $ne: null } }&lt;/code&gt; and return the first user it encounters.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution: explicit typing and normalization of input data using libraries like mongo-sanitize or manual validation:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;sanitizeInput&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Record&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;unknown&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nb"&gt;Record&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="na"&gt;clean&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Record&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{};&lt;/span&gt;
  &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;entries&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;string&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Invalid input type&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nx"&gt;clean&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;clean&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But it's better to use proven validators, &lt;strong&gt;such as Zod or class-validator&lt;/strong&gt;, to prohibit objects with suspicious properties at the DTO level.&lt;/p&gt;




&lt;h3&gt;
  
  
  Raising the Bar. Case Study 3: Prototype Pollution
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feozt8h7889jedo3k77c0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feozt8h7889jedo3k77c0.png" alt="Prototype pollution in Typescript" width="800" height="483"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In Node.js&lt;/strong&gt;, objects inherit from &lt;code&gt;Object.prototype&lt;/code&gt;, and changing this prototype can have catastrophic consequences, ranging from logic changes to remote code execution.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;An example of such code is a deep merge function:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Danger function&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;deepMerge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;any&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;any&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;key&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nx"&gt;source&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;source&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;object&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;source&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{};&lt;/span&gt;
      &lt;span class="nf"&gt;deepMerge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="nx"&gt;source&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;source&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;put&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/settings&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;userSettings&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;readFileSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;settings.json&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;utf-8&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
  &lt;span class="c1"&gt;// Danger&lt;/span&gt;
  &lt;span class="nf"&gt;deepMerge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;userSettings&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;writeFileSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;settings.json&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;userSettings&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
  &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ok&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;And if the request is:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"__proto__"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"isAdmin"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After such a merge, any new object &lt;strong&gt;will have&lt;/strong&gt; &lt;code&gt;isAdmin === true&lt;/code&gt;. This could bypass authorization checks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Protection:&lt;/strong&gt; Never use recursive merges without property checks. Modern libraries (lodash.merge) offer protection, but it's safer not to use them for user data at all. &lt;strong&gt;It's better to explicitly define the schema:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;z&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;zod&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;SettingsSchema&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;z&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;object&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;z&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;enum&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;light&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dark&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt;
  &lt;span class="na"&gt;notifications&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;z&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;boolean&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;put&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/settings&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;parsed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;SettingsSchema&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;safeParse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;parsed&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;success&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;400&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;errors&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;parsed&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="c1"&gt;// Work only with parsed.data&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Zod will automatically discard all undeclared keys, including &lt;code&gt;proto&lt;/code&gt; and &lt;code&gt;constructor&lt;/code&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Secure Integration of JWT and Sessions
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;JWT has become an industry standard&lt;/strong&gt;, but its misuse often leads to token theft and privilege escalation.&lt;/p&gt;

&lt;h3&gt;
  
  
  Case 4: Lack of Algorithm Validation
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Let's look at the vulnerable code:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;jwt&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;jsonwebtoken&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/profile&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;token&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;authorization&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt; &lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;401&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;decoded&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;jwt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;verify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;publicKey&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="c1"&gt;// Attack: The attacker signs the token with the "none" or HS256 algorithm with the public key.&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the library doesn't specify an acceptable algorithm, you can use the "none" algorithm or a symmetric algorithm if you know the public key.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution: explicitly specify acceptable algorithms.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;decoded&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;jwt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;verify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;publicKey&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;algorithms&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;RS256&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="c1"&gt;// or ['ES256']&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Additionally, &lt;strong&gt;never use &lt;code&gt;jwt.decode()&lt;/code&gt; for verification. Only &lt;code&gt;verify&lt;/code&gt;&lt;/strong&gt;.&lt;/p&gt;




&lt;h3&gt;
  
  
  Case 5: Secrets in Code and Configurations
&lt;/h3&gt;

&lt;p&gt;Accidentally committing a &lt;code&gt;.env&lt;/code&gt; file with &lt;code&gt;JWT_SECRET=super-secret&lt;/code&gt; to the repository is a classic example. &lt;strong&gt;TypeScript doesn't scan string contents&lt;/strong&gt;. Use:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;process.env&lt;/code&gt; and tools like dotenv-vault.&lt;/li&gt;
&lt;li&gt;Configuration validation at startup, using Zod.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Configuration verification using Zod:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;envSchema&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;z&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;object&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;JWT_SECRET&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;z&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;string&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;32&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="na"&gt;DB_URL&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;z&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;string&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;url&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;env&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;envSchema&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the variable is missing or incorrect, the application will crash on startup with a clear error.&lt;/p&gt;




&lt;h3&gt;
  
  
  Protecting against SSTI (Server-Side Template Injection) in template engines
&lt;/h3&gt;

&lt;p&gt;If you outsource HTML rendering to the server (Nunjucks, EJS, Pug), careless passing of user input to the template can lead to code execution.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example of vulnerability:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/hello&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;hello&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="c1"&gt;// EJS Template: &amp;lt;h1&amp;gt;Hi &amp;lt;%= name %&amp;gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Although &lt;code&gt;&amp;lt;%= %&amp;gt;&lt;/code&gt; escapes HTML, in some engines it's possible to inject executable code via template engine parameters (as with &lt;code&gt;{ constructor: ... }&lt;/code&gt;). The best defense is to never pass raw input to a template without context processing and to avoid using advanced template engine features (such as &lt;code&gt;eval&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;If you're using &lt;strong&gt;Next.js or React for SSR&lt;/strong&gt;, a similar attack can occur via &lt;code&gt;dangerouslySetInnerHTML&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Profile&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;bio&lt;/span&gt; &lt;span class="p"&gt;}:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;bio&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;dangerouslySetInnerHTML&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{{&lt;/span&gt; &lt;span class="na"&gt;__html&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;bio&lt;/span&gt; &lt;span class="p"&gt;}}&lt;/span&gt; &lt;span class="sr"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, TypeScript assumes that &lt;code&gt;bio = string&lt;/code&gt;, but the variable could contain &lt;strong&gt;XSS&lt;/strong&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;The obvious rule&lt;/strong&gt;, even from the method's name, is to never use &lt;code&gt;dangerouslySetInnerHTML&lt;/code&gt; with unvalidated user input, and if necessary, use &lt;code&gt;DOMPurify&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Frontend: Browser Security
&lt;/h2&gt;

&lt;p&gt;On the client, TypeScript gives a false sense of security. Let's look at the main attack vectors where types won't help.&lt;/p&gt;

&lt;h3&gt;
  
  
  Case 6: XSS via HTML injection
&lt;/h3&gt;

&lt;p&gt;As shown above, passing unescaped text to innerHTML or the &lt;code&gt;dangerouslySetInnerHTML&lt;/code&gt; JSX attribute is a direct route to XSS. But there are less obvious places.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Unsafe code in React:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Comment&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;text&lt;/span&gt; &lt;span class="p"&gt;}:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;`https://example.com/?q=&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;text&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nx"&gt;Search&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/a&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c1"&gt;// Если text = "javascript:alert(1)"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The browser &lt;strong&gt;will execute JavaScript on click&lt;/strong&gt;. TypeScript is unaware of the context of the string.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Protection:&lt;/strong&gt; URL validation and use of &lt;code&gt;encodeURIComponent&lt;/code&gt;. A &lt;strong&gt;Content Security Policy (CSP)&lt;/strong&gt; with strict directives is also a good idea.&lt;/p&gt;




&lt;h3&gt;
  
  
  Case 7: Sensitive Data Leaking into the Build
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Environment variables (API keys, internal URLs)&lt;/strong&gt; often leak into the client bundle because the developer used &lt;code&gt;process.env.NEXT_PUBLIC_*&lt;/code&gt; or forgot about the server/client boundary. &lt;strong&gt;TypeScript doesn't distinguish between where the code will be executed&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Protection:&lt;/strong&gt; Clearly separate environment variables. In Next.js, for example, only variables prefixed with &lt;code&gt;NEXT_PUBLIC_&lt;/code&gt; are accessible on the client. Everything else should only be read on the server (getServerSideProps / API Routes).&lt;/p&gt;




&lt;h3&gt;
  
  
  Case 8: CSRF with Mutations
&lt;/h3&gt;

&lt;p&gt;If your cookies are passed automatically and your API accepts POST requests without additional validation, an attacker can trick the user into sending an unwanted request.&lt;/p&gt;

&lt;p&gt;TypeScript won't automatically add a &lt;strong&gt;CSRF token&lt;/strong&gt;. You need to implement either a synchronous token or a SameSite cookie and Origin/Referer validation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;An example of a simple check in Next.js API routes:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;NextResponse&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;next/server&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;NextRequest&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;next/server&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;allowedOrigins&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://myapp.com&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;middleware&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;NextRequest&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;origin&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;origin&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;method&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;GET&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;origin&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;allowedOrigins&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;origin&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;NextResponse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;403&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;NextResponse&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;next&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Dependencies and Supply Chain
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;TypeScript projects pull hundreds of packages.&lt;/strong&gt; Each dependency can become an entry point. Typing doesn't protect against malicious code in postinstall scripts or obfuscated packages.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Specific Incident: Event-Stream&lt;/strong&gt;&lt;br&gt;
In 2018, the popular &lt;code&gt;event-stream&lt;/code&gt; npm package was compromised: malicious code was added to it that stole cryptocurrency keys from another package. TypeScript was powerless here: the malware can be buried deep in dependencies and contain no types at all.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Protective Measures:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Use &lt;code&gt;npm audit&lt;/code&gt;&lt;/strong&gt;, snyk, and socket.dev.&lt;/li&gt;
&lt;li&gt;Check package licenses and reputation.&lt;/li&gt;
&lt;li&gt;Minimize the number of dependencies.&lt;/li&gt;
&lt;li&gt;Add a check for known vulnerabilities to CI/CD.&lt;/li&gt;
&lt;/ul&gt;


&lt;h3&gt;
  
  
  Types as an Element of Security Infrastructure
&lt;/h3&gt;

&lt;p&gt;Despite all of the above, TypeScript can significantly enhance security if used consciously:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Typed DTOs and strict interfaces.&lt;/strong&gt; Use not just "any" types, but precise types, enumerations, and discriminated unions. This eliminates many validation errors even at the coding stage.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Branded types (nominal typing).&lt;/strong&gt; For example, we can create a &lt;code&gt;SafeHtml&lt;/code&gt; type that can only be accessed through a sanitization function.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Exhaustive switches and protection against incompleteness.&lt;/strong&gt; Ensures that all possible states are handled (for example, when parsing authentication statuses).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;An example of a protected &lt;code&gt;SafeHtml&lt;/code&gt; type:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;SafeHtml&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;readonly&lt;/span&gt; &lt;span class="na"&gt;__brand&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;unique&lt;/span&gt; &lt;span class="nx"&gt;symbol&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;sanitizeHtml&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nx"&gt;SafeHtml&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;DOMPurify&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sanitize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;SafeHtml&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;SafeHtml&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;app&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Level Up. Five subtle modern attacks on TypeScript applications
&lt;/h2&gt;

&lt;p&gt;Now we'll move on to threats that rarely make it into basic guides, but are increasingly common in real-world projects. All examples focus on the TypeScript stack.&lt;/p&gt;

&lt;h3&gt;
  
  
  Dependency Confusion via Typed Packages
&lt;/h3&gt;

&lt;p&gt;An attacker &lt;strong&gt;publishes a package with an internal name&lt;/strong&gt; to the public npm, but with a higher version. TypeScript projects are particularly vulnerable due to the habit of using &lt;code&gt;@types/*&lt;/code&gt; or corporate naming conventions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt; Your company uses an internal package &lt;code&gt;@mycompany/auth&lt;/code&gt;, which is stored in a private registry. The attacker publishes &lt;code&gt;@mycompany/auth&lt;/code&gt; to npm with &lt;strong&gt;version 99.0.0&lt;/strong&gt; and malicious code in the postinstall. If .npmrc doesn't specify a strict scope registry, npm install will pull in the public version.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Code from dangerous repo (index.d.ts and index.js)&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;login&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;login&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;password&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nx"&gt;boolean&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// In JS: process.env.JWT_SECRET send to the hacker server&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Security:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Configure .npmrc&lt;/strong&gt; to link the scope to a private registry.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use&lt;/strong&gt; &lt;code&gt;npm install --prefer-offline&lt;/code&gt; and block queries to the public registry for internal names at the network level.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;In the CI pipeline, check package integrity&lt;/strong&gt; using &lt;code&gt;npm audit --audit-level=high&lt;/code&gt; and compare hashes.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Timing attack on string comparisons (JWT, API keys)
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;A classic mistake:&lt;/strong&gt; checking tokens or keys using &lt;code&gt;===&lt;/code&gt;. In Node.js, string comparisons are performed byte by byte and take varying amounts of time. An attacker can measure the response and guess the token character by character.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example of vulnerable code:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;expectedApiKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;API_KEY&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/webhook&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;apiKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;x-api-key&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;apiKey&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="nx"&gt;expectedApiKey&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;  &lt;span class="c1"&gt;// Danger!&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;403&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Forbidden&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the lengths are unequal, the comparison fails immediately, but &lt;strong&gt;if the first character is correct, it takes a little longer&lt;/strong&gt;. By repeating the queries with different values, the key can be recovered.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Security:&lt;/strong&gt; Use &lt;code&gt;crypto.timingSafeEqual&lt;/code&gt; to compare secrets.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;timingSafeEqual&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;crypto&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;constantTimeCompare&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nx"&gt;boolean&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;bufA&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Buffer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;bufB&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Buffer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;timingSafeEqual&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;bufA&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;bufB&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And be sure to normalize the length so that the pause does not give away the length of the key.&lt;/p&gt;




&lt;h3&gt;
  
  
  GraphQL: Introspection Abuse and Argument Injections
&lt;/h3&gt;

&lt;p&gt;On the &lt;strong&gt;Apollo Server (TypeScript)&lt;/strong&gt; backend, introspection is often left enabled in production. This allows an attacker to obtain the full schema and find secret mutations or fields accessible only to admins. Injection via unvalidated arguments becomes even more dangerous.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Resolver vulnerability:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;resolvers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;Query&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;user&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="na"&gt;_&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;unknown&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;args&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// id  doesn't checked&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;raw&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`SELECT * FROM users WHERE id = '&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;'`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Steps to protect:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Disable introspection in production.&lt;/li&gt;
&lt;li&gt;Validate arguments using Zod or graphql-scalars.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example of disabling introspection in configs:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;server&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;ApolloServer&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="nx"&gt;typeDefs&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;resolvers&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;introspection&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;NODE_ENV&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;production&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Validation example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;mport&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;z&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;zod&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;userIdSchema&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;z&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;string&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;uuid&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="nl"&gt;user&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;unknown&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;userIdSchema&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;query&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;SELECT * FROM users WHERE id = $1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  SSRF via URL parsing in Node.js
&lt;/h3&gt;

&lt;p&gt;Many applications accept URLs from the user (for example, to import an avatar). &lt;strong&gt;Attackers bypass these checks using Unicode tricks or redirects.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example of vulnerable code:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/import&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;url&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;parsedUrl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;URL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;parsedUrl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hostname&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;localhost&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;parsedUrl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hostname&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;127.0.0.1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;400&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Invalid URL&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="c1"&gt;// ...&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Bypass hostname verification:&lt;/strong&gt; &lt;code&gt;http://127.0.0.1:80@evil.com&lt;/code&gt; (the part before the @ is considered credentials, resulting in &lt;code&gt;hostname = evil.com&lt;/code&gt;, and the request goes to &lt;code&gt;127.0.0.1&lt;/code&gt;). &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Another example:&lt;/strong&gt; &lt;code&gt;http://0x7f.0.0.1/&lt;/code&gt; (IP hex notation).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Protection:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Don't parse the URL yourself&lt;/strong&gt;. Use a library like is-ip or check the final IP after DNS resolution.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Restrict the scheme to http and https&lt;/strong&gt;. Disallow raw IP.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;promises&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;dns&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dns&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;resolveIp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;hostname&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;URL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;hostname&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;addresses&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;dns&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;resolve4&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;hostname&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;addresses&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt; &lt;span class="c1"&gt;// упрощённо&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Checks for private ranges&lt;/span&gt;
&lt;span class="c1"&gt;// (10/8, 172.16/12, 192.168/16, 127/8)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  RCE via unsafe deserialization in TypeScript
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Some libraries allow functions to be serialized or eval'd during deserialization for convenience.&lt;/strong&gt; For example, &lt;code&gt;serialize-javascript&lt;/code&gt; (used in Next.js) &lt;strong&gt;is safe&lt;/strong&gt;, but packages like &lt;code&gt;node-serialize&lt;/code&gt; and &lt;code&gt;cookie-serialize&lt;/code&gt; allow RCE to be replicated.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example of vulnerable code:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;serialize&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;node-serialize&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/state&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;serialize&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;unserialize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;cookies&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="c1"&gt;// state can contain an objects with code&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Attack example:&lt;/strong&gt; a state cookie with a serialized object, where the rce field is: &lt;code&gt;"_$$ND_FUNC$$_function(){ require('child_process').exec('rm -rf /') }"&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Protection:&lt;/strong&gt; Never use deserialization that can restore functions. Use only JSON. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;cookies&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;{}&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If complex types are required, use &lt;code&gt;zod&lt;/code&gt; &lt;strong&gt;for validation&lt;/strong&gt; after JSON.parse, but do not run the code. &lt;strong&gt;Any imports of libraries with extended serialization should be prohibited.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  A practical security checklist for a TypeScript project
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;For the backend:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Validate all incoming data&lt;/strong&gt; via Zod / class-validator / io-ts. No any or as.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Parameterized database queries&lt;/strong&gt;, no string concatenation (even within Raw() and QueryBuilder methods).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Clean objects from &lt;code&gt;proto&lt;/code&gt; and &lt;code&gt;constructor&lt;/code&gt;&lt;/strong&gt; (or use safe map/reduce).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fixed JWT algorithms&lt;/strong&gt;, short token lifetimes, and refresh tokens with rotation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Secure CORS settings&lt;/strong&gt; (no * with credentials).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Logging without&lt;/strong&gt; token/password leaks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Helmet-like&lt;/strong&gt; middleware.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;For the frontend:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;No &lt;code&gt;dangerouslySetInnerHTML&lt;/code&gt;&lt;/strong&gt; without &lt;code&gt;DOMPurify&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CSP headers&lt;/strong&gt; prohibiting inline scripts.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Proper use of &lt;code&gt;encodeURIComponent&lt;/code&gt;&lt;/strong&gt; and URL validation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Separation of sensitive environment variables:&lt;/strong&gt; only what is truly needed is included in the client code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CSRF protection:&lt;/strong&gt; SameSite=Strict/Lax, Origin check, tokens for state-changing requests.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Regular and very careful updating&lt;/strong&gt; of dependencies.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;General practices:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Linter with security rules&lt;/strong&gt; (eslint-plugin-security).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Static analysis with type checking&lt;/strong&gt;, but not excessively so; remember that any casting breaks security.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Runtime type checks&lt;/strong&gt; (ts-runtime, type guards) for server data, as the API response may also be different from what you described in the interface.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;TypeScript is a truly powerful tool, but it's not a bodyguard.&lt;/strong&gt; Strong typing reduces bugs and makes code more predictable, but it doesn't eliminate classic web vulnerabilities. Today, we examined real-world examples where the compiler is completely blind to the dangers: from SQL substitution (even through high-level TypeORM operators) to prototype pollution, timing attacks, and deserialization.&lt;/p&gt;

&lt;p&gt;Furthermore, the last five cases demonstrate that attacks are adapting to modern technologies, and defenses must evolve.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;The main takeaway:&lt;/strong&gt; think of types as the foundation on which you build a multi-layered security system. Validate everything at the boundaries of trust, never trust the client, and remember that any is not a type, but a security hole.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Security is a process, not a final state.&lt;/strong&gt; Make your TypeScript not only strict but also secure.&lt;/p&gt;

&lt;p&gt;Thanks for reading. &lt;br&gt;
What other types of vulnerabilities would you like to explore, perhaps in more depth and from less obvious perspectives?&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>security</category>
      <category>frontend</category>
      <category>backend</category>
    </item>
    <item>
      <title>DLSS 5 is not a failure. The Future of rendering: A deep technical look at new approaches after 15 years in Game Development</title>
      <dc:creator>Devs Daddy</dc:creator>
      <pubDate>Wed, 22 Apr 2026 21:58:53 +0000</pubDate>
      <link>https://forem.com/devsdaddy/dlss-5-is-not-a-failure-the-future-of-rendering-a-deep-technical-look-at-new-approaches-after-15-7ad</link>
      <guid>https://forem.com/devsdaddy/dlss-5-is-not-a-failure-the-future-of-rendering-a-deep-technical-look-at-new-approaches-after-15-7ad</guid>
      <description>&lt;p&gt;Hello everyone! Before we start, let's get to know a few people we haven't met yet. My name is Elijah, I am a technical director at a company that develops products based on machine learning. Previously, I worked in game development for 15 years and went through several technical milestones. I was partly inspired to write this article by the recent srach that appeared after the announcement of DLSS 5 from Nvidia.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In this article, we will &lt;strong&gt;omit the marketing jamb of Nvidia&lt;/strong&gt; itself and the technically crude demos, but rather dive into the near-term &lt;strong&gt;technical future that awaits us in the gamedev industry&lt;/strong&gt;, going through the history of the graphics pipeline.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  The beginning of a revolution in the graphics pipeline
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwo5dzu5t2m1nwpae7n9w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwo5dzu5t2m1nwpae7n9w.png" alt="DLSS vs FSR vs TSR" width="800" height="375"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There has been a &lt;strong&gt;really huge shift in the rendering architecture of games over the past five years&lt;/strong&gt;. If for two decades before that, progress rested on the inexorable mathematics of Moore's law, where improving rendering quality was reduced to increasing computing power and increasing the number of polygons and shaders, today everything has changed. Now, in order to achieve high visual quality in games, it is not brute force head-on, but &lt;strong&gt;new approaches that change the established essence of building a game image over decades, including on the basis of AI technologies&lt;/strong&gt;. Today, more than 80% of all pixels on the screen in the most advanced (from a technical point of view) games go not the classic way, but mixed approaches and new tricks (new approaches to calculating light, super-sampling based on AI, etc.).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Today we will focus on how it influenced (and will continue to influence) AI is like rendering in games to understand the essence of a shift in graphics&lt;/strong&gt;. To do this, we will initially look at two key topics: first, the &lt;strong&gt;fundamental differences between DLSS and all previous approaches to resolution enhancement&lt;/strong&gt; and anti-aliasing (from SSAA to TAAU), and secondly, the place that neural network scaling occupies in the modern graphics pipeline, after which we will review the near future of rendering in games.&lt;/p&gt;




&lt;h2&gt;
  
  
  From super-sampling to neural synthesis of a scene
&lt;/h2&gt;

&lt;p&gt;To assess the place of DLSS (including the future 5th version) in the graphical pipeline, we will trace the evolution of anti-aliasing and scaling from the very first implementations to the modern approach using AI computing.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Era of "pure mathematics": SSAA, MSAA, FXAA and their limitations
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F02jz528zjq72a00f4kd5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F02jz528zjq72a00f4kd5.png" alt="Surely many of us will remember these terrible letter combinations when choosing anti-aliasing in the game settings." width="686" height="386"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Classical methods of dealing with "ladders" at the boundaries of game objects were based on a simple but computationally expensive principle: processing a higher-resolution image or parts of it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let's look at three classic anti-aliasing algorithms in games:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;SSAA (Supersampling Anti-Aliasing):&lt;/strong&gt; The most "honest", but also voracious method. The scene is rendered at a &lt;strong&gt;resolution higher than the user's target&lt;/strong&gt; (for example, 4K for output to an FHD monitor), and then the resulting frame is compressed back to the desired size. &lt;strong&gt;SSAA processes each subpixel&lt;/strong&gt;, including shading, which gives a reference image quality, but leads to a drop in performance (I hope you understand why). For modern games with complex shaders and geometry, this approach is impractical.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;MSAA (Multisample Anti-Aliasing):&lt;/strong&gt; This method appeared as an attempt &lt;strong&gt;to optimize SSAA&lt;/strong&gt;. The essence of optimization boils down to the fact that shading is processed only once for each primitive (for example, a triangle) inside a pixel, and not for each sample, as SSAA does. Although this approach significantly reduces the load on the GPU, it is worth considering that MSAA effectively smooths only the edges of the geometry, but does not cope with other elements of the pipeline, such as smoothing textures. Also, its cost is still high for complex scenes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;FXAA (Fast Approximate Anti-Aliasing):&lt;/strong&gt; Post-processing smoothing, which analyzes a ready-made 2D frame, searches for high-contrast borders in it and blurs them. This is the cheapest method in terms of performance, but its main drawback is the inevitable "soap" of the entire image, including textures and interface elements, which leads to a loss of clarity and detail.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  The Age of Temporal Accumulation: TAA and its Heirs (TAAU)
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F25btn40oy6o7me3c43kz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F25btn40oy6o7me3c43kz.png" alt="TAA in rendering pipeline" width="800" height="272"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A key breakthrough occurred with the transition to temporal methods that use information not only from the current frame, but also from previous ones.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What has changed in the approaches:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;TAA (Temporal Anti-Aliasing):&lt;/strong&gt; Instead of rendering each pixel, TAA slightly shifts the camera position each frame, accumulates information from previous frames using motion vectors of objects, and then calculates the average value. This allows you to get a quality close to SSAA, with performance comparable to a single frame rendering. TAA has become an industry standard for many years, but it has its own fundamental problems: gouging, loss of detail on small and fast-moving objects, and the overall "soapy" feeling of the picture in some implementations and scenes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TAAU (Temporal Anti-Aliasing Upsampling):&lt;/strong&gt; The logical development of TAA. Realizing that temporal accumulation allows you to restore details from subpixel information, the developers began to use it to scale the image, rendering the scene in lower resolution and "upscale" to high resolution using frame history.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;It is TAAU that is the direct predecessor of DLSS&lt;/strong&gt;, but with one critical difference: &lt;strong&gt;TAAU relies on hard-coded rules&lt;/strong&gt; and is not able to "understand" the scene, but only mathematically averages pixels, which often leads to artifacts.&lt;/p&gt;

&lt;h3&gt;
  
  
  The DLSS Revolution: From CNN to Vision Transformer
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;NVIDIA DLSS (Deep Learning Super Sampling) and its FSR counterpart&lt;/strong&gt; have made a qualitative leap by replacing purely mathematical TAAU approaches with machine learning models capable of making more "intelligent" decisions about how to restore an image.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The first generations used convolutional neural networks (CNN)&lt;/strong&gt;. Their main disadvantage is "myopia": the model analyzed pixels only within a limited spatial window (the receptive field or the area of the input image). This led to problems familiar to gamers: if an object moved too fast, CNN would "lose" sight of it, which caused flickering and gushing on small details like foliage, wires, or hair.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2rft7fsl5p1j2v79uaza.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2rft7fsl5p1j2v79uaza.png" alt="How models work on Vision Transformer" width="800" height="452"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The transition to the Vision Transformer architecture in the 4th version of DLSS&lt;/strong&gt; has become a fundamental progress. Unlike CNN, Transformer can evaluate the significance and relationship of any pixels in a frame, regardless of the distance between them, thanks to an additional attention mechanism. The model learned to "understand" the context of the entire scene, which made it possible to radically increase image stability by reducing the number of artifacts and, for the first time, bring the image closer to the native resolution after upscaling (and sometimes surpass it in clarity).&lt;/p&gt;

&lt;h3&gt;
  
  
  Technical integration into the graphics pipeline: DLSS's place in the rendering pipeline
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;For those who are interested in the topic of how graphics pipelines work and what shaders have to do with it, I wrote an article about this a long time ago using the example of the Unity game engine. However, the essence of + is the same for all game engines. &lt;a href="https://dev.to/devsdaddy/how-it-works-3d-games-a-bit-about-shaders-and-how-the-graphics-pipeline-works-in-unity-4ajg"&gt;So I recommend reading it for a better understanding of the topic&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;DLSS is not a "black box"&lt;/strong&gt; that simply receives a low resolution input and outputs a high one. This is a complex system that is deeply integrated into the rendering process, requiring developers not only to call the API, but also to prepare specific data. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Therefore, when you see a bad DLSS, it's probably the game developer himself, not the technology.&lt;/strong&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Input data: what is needed for DLSS to work?
&lt;/h4&gt;

&lt;p&gt;For DLSS to work correctly, the game's graphics engine must provide a special set of buffers, each of which is critically important to the algorithm:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Color Buffer:&lt;/strong&gt; Roughly speaking, this is a frame rendered in low resolution. This is a "rough sketch" based on which the final image will be built.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Motion Vectors:&lt;/strong&gt; A critical component. For each pixel, this buffer shows where it has moved compared to the previous frame. This allows DLSS to understand the dynamics of a scene, correctly link pixels from different frames, and avoid the effect of gouging.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Depth Buffer:&lt;/strong&gt; Information about the distance from the camera to each pixel. It helps the model understand the structure of the scene and which objects overlap each other, which is especially important for proper processing of the edges of the geometry.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Jitter Offsets:&lt;/strong&gt; To get more information than is contained in one frame, the camera is slightly shifted by a fraction of a pixel in each frame according to a special pattern (as in the previously described TAA). DLSS must know exactly the amount of this offset in order to "subtract" it from the motion vectors and correctly combine pixels from different frames.&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  How DLSS is integrated into the pipeline
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn06a86rses8t3ry9fbyw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn06a86rses8t3ry9fbyw.png" alt="Classic rendering pipeline" width="723" height="170"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DLSS is not embedded at any time&lt;/strong&gt;, but in a strictly defined place of the graphic pipeline. Integration with the game engine takes place through an open SDK, which provides an interface for technologies (DLSS, Reflex, etc.).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example of pipeline stages based on DLSS operation:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Geometry rendering and shading:&lt;/strong&gt; The game engine does all the "hard" work: calculates geometry, lighting, materials, and shadows. &lt;strong&gt;All this happens in a reduced resolution&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Early post-processing:&lt;/strong&gt; DLSS must be embedded before effects such as film grain, chromatic aberration, vignettes, and most importantly, before the user interface (UI). This is necessary for the neural network to work with a "clean" image of the scene, and not with effects superimposed on top of it, which can confuse it and distort the final result.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;DLSS call:&lt;/strong&gt; At this stage, all prepared input data (color buffers, depths, motion vectors) is transferred to DLSS. The model processes them using its weights and generates the final frame in the target (high) resolution.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Late post-processing and UI:&lt;/strong&gt; After DLSS has done its job, effects that should remain "native" to the monitor resolution (chromatic aberration, vignette, etc.) are applied on top of the resulting high-quality image, and, most importantly, the interface is at the target resolution, remaining as clear and undistorted as possible.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Screen output:&lt;/strong&gt; The final frame is sent to the display.&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;All this paves the way for mass adoption of technologies, especially when DirectX 12 and other vendors discover new DLSS-like approaches based on AI rendering (compression of textures, materials) at the API level, making them a standard part of the toolkit of a modern developer.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  DLSS 5: Paradigm Shift towards AI scene Synthesis
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvn13xn140yejxvzbi4ou.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvn13xn140yejxvzbi4ou.png" alt="Nvidia DLSS 5" width="760" height="423"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DLSS 5 gives a start to redefining the very approach to problem statement&lt;/strong&gt;. If previous versions worked with an &lt;strong&gt;already rendered frame&lt;/strong&gt;, restoring or completing pixels, the new model uses the structural data of the engine: depth buffer, albedo, motion vectors, normals, identifiers of materials and lighting. &lt;strong&gt;The network doesn't just "finish painting" - it rethinks the visual properties of the scene&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NVIDIA claims that DLSS 5&lt;/strong&gt; is capable of analyzing the semantics of a scene: recognizing skin, hair, fabrics, various types of lighting, and generating more accurate pixels for subsurface scattering on the skin or more realistic material responses. We are talking about a controlled modification of the final image, which remains deterministic and temporally stable.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The fact that many "experts" were swearing at the final result is more likely now - it's just the dampness of the technology itself and the "handedness" of the developers who helped create the techno demonstration. &lt;strong&gt;It is worth considering that the approach to rendering itself is changing, so the first steps will be jackal, but earlier technologies without AI also went this way.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Multi Frame Generation: from linear interpolation to adaptive synthesis
&lt;/h3&gt;

&lt;h3&gt;
  
  
  The mathematics of frame generation
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1bwcmj71gte5wl64tb7h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1bwcmj71gte5wl64tb7h.png" alt="Most of the technologies were not invented immediately - this is an evolution that the average person did not notice." width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In the classical frame generation scheme (DLSS 3)&lt;/strong&gt;, one interpolated frame was generated for each rendered frame, which resulted in a speed increase of about 100%. &lt;strong&gt;DLSS 4 increased the gain by about two more times&lt;/strong&gt; (three generated frames per one rendered one).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The key question is:&lt;/strong&gt; at what FPS does this make sense? Let's assume that with an input stream of 60 FPS after super-sampling, the output can reach 360 FPS on the display. This corresponds to a time window of ~16.6 ms between rendered frames, within which the neural network must predict five intermediate states of the scene. Think about the answer yourself and write it in the comments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In general, in the Blackwell architecture&lt;/strong&gt;, which serves as the basis for motion prediction, linear motion vector interpolation becomes insufficient at high generation coefficients. DLSS 4.5 adds dynamic coefficient adjustment: in scenes with high complexity (for example, particle explosions), the model can reduce the coefficient to maintain quality, and in relatively static scenes it can increase it. &lt;strong&gt;However, again, it's up to the developers.&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;And that's where it's worth making a remark. Nvidia engineers are people who work solely to move their technology forward, and graphics programmers who work on rendering are not only listed in the red book, firstly, they are used to established approaches and cannot quickly switch to the updated pipeline of the render without breaking anything, and secondly Like everyone else, they stick to release dates. &lt;strong&gt;If you have an idea of what is meant by "rebuild the graphics pipeline", then you should understand why at first there are inevitable shoals in the use of new technology.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  The problem is input delays (input lag) and the solution is via Reflex
&lt;/h4&gt;

&lt;p&gt;The generation of intermediate frames fundamentally increases the input lag: you see, the generated frame does not contain a reaction to user input, this reaction appears only in the next rendered frame.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NVIDIA compensates&lt;/strong&gt; for this with Reflex technology, which synchronizes the CPU and GPU so that the rendering queue is minimal. However, the implementation also strongly depends on the game engine and the correctness of embedding into the overall lifecycle of rendering and the rest of the logic.&lt;/p&gt;




&lt;h2&gt;
  
  
  What if you compress data instead of pixels?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;DLSS is certainly cool and well-known.&lt;/strong&gt; But this is just one of the approaches where &lt;strong&gt;AI is used in the rendering process&lt;/strong&gt;. Let's look at other approaches.&lt;/p&gt;

&lt;h3&gt;
  
  
  AI-assisted texture compression: saving video memory
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7lksgatxvvljckz3gv9t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7lksgatxvvljckz3gv9t.png" alt="Why we need to compress pixels when you can compress textures? After all, they are already shrinking." width="768" height="432"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;One of the most pressing problems of modern game development is the huge increase in texture volumes.&lt;/strong&gt; Traditional block compression methods (BC1-BC7) achieve coefficients 4:1 &amp;lt;=&amp;gt; 8:1, but their effectiveness comes down to fundamental limitations: compression occurs independently for each block, without taking into account the global texture structure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The engineers decided to approach the task in a fundamentally different way:&lt;/strong&gt; instead of storing a compressed image, a trained neural network (or its weights) is stored, capable of reconstructing a texture of arbitrary resolution in runtime. For example, &lt;strong&gt;NVIDIA claims&lt;/strong&gt; a sevenfold reduction in the use of VRAM and system memory compared to traditional block-compressed textures with comparable visual quality.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Technically, it works as follows:&lt;/strong&gt; at the build stage of the game, textures are passed through a training procedure that takes less than a minute for thousands of assets (depending on the hardware, of course). The result is a compact representation for the model, which is decompressed by tensor kernels in real time when loaded into memory. Since unpacking takes place on the fly, there is no need to store all MIP levels in video memory at the same time. The AI can generate the required level on demand.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For AAA games, this means&lt;/strong&gt; not only saving video memory, but also drastically reducing the size of the games themselves, speeding up downloads, and allowing you to increase texture density without increasing memory requirements.&lt;/p&gt;

&lt;h3&gt;
  
  
  Compression of shaders and materials
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F86jvzwdzj0gu6vyzna3t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F86jvzwdzj0gu6vyzna3t.png" alt="Photo-realistics shaders are heeeeavyyy" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Complex materials are layered structures that combine dozens of maps and hundreds of mathematical operations&lt;/strong&gt;. Rendering high-level materials (e.g. porcelain, silk, multilayer leather) in real time has so far been impractical due to the high computational cost.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;AI shaders use trained neural networks to calculate&lt;/strong&gt; complex shader code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Architecturally, this means that instead of executing the full shader graph on each pixel, the GPU performs inference&lt;/strong&gt;, which outputs the final shader parameters. The gain is achieved due to the fact that tensor kernels perform matrix operations much more efficiently than shader kernels.&lt;/p&gt;

&lt;h3&gt;
  
  
  Inference instead of ray tracing
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Everyone knows how voracious ray tracing remains&lt;/strong&gt; - Ray Tracing and, in particular, Path Tracing. Path tracing requires tracing hundreds or thousands of rays per pixel to converge indirect lighting. The new approach allows us to replace most of this work with an inference: after tracing one or two bounces, the neural network predicts the result of an infinite number of subsequent bounces.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyblm0mpr8laf8fcwchfd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyblm0mpr8laf8fcwchfd.png" alt="AI Based Path Tracing" width="650" height="359"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For example, a similar technology (NRC) has already become available through the RTX Global Illumination SDK&lt;/strong&gt; and will soon appear in RTX Remix. A practical consequence of this approach is the ability to achieve the visual quality of traditional Path Tracing with performance comparable to simpler global lighting techniques.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A small note. All the described technologies rely on specialized computing units. The evolution of tensor core from each generation directly determines how effectively AI rendering models work.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Based on this, RTX 20/30 series users receive identical image quality, for example from DLSS 4.5, but with a significant drop in performance due to the lack of native FP8/FP4 support in tensor cores.&lt;/p&gt;




&lt;h2&gt;
  
  
  Let's look into the inevitable future: AI rendering as a new standard
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdg02rtclwwxf7i4l0pea.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdg02rtclwwxf7i4l0pea.png" alt="The future of AI rendering?" width="800" height="448"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So, having talked about current technologies and a changing approach (somewhere else not ideal, experimental, but already gaining momentum), let's look into the near future of rendering in AI-based games.&lt;/p&gt;

&lt;h3&gt;
  
  
  Development trajectory until 2030
&lt;/h3&gt;

&lt;p&gt;Analyzing the current technological vectors and already available solutions, we can safely predict several key areas:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Complete replacement of traditional shaders with inference:&lt;/strong&gt; the first technologies like RTX Neural Shaders already demonstrate that neural networks can accelerate complex calculations on materials more efficiently than handwritten shader code, especially due to the improved architecture of tensor cores. &lt;strong&gt;The next step, of course, is the unification of all materials for the AI model, where the shader is compiled into the weights of a small inference&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Smooth transition from frame generation to scene generation:&lt;/strong&gt; existing technologies for working with scene primitives (geometry, lighting, textures) are leading the way to a more optimized and advanced game production pipeline at the stage level, which will free the hands of artists and technical artists, eliminating the routine work of optimizing scenes at the AI level. And then, as an option, it is the generation of any primitives in order to select the initial sketches for the artists in seconds, rather than hours of manual work.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hybrid computing models:&lt;/strong&gt; Modern video cards already contain separate tensor cores, raytracing cores, and shader cores. Future architectures are likely to spread these specialized blocks even further, allowing classical rendering, ray tracing, and inference to be performed in parallel.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Standardization of AI rendering:&lt;/strong&gt; Microsoft has already added support for AI rendering to DirectX, which paves the way for universalization (at least at the DirectX API level). The same ARM is developing its own GDK for developers, opening the door to super-sampling and denoising based on AI for mobile devices.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;However, with all the achievements, there are still a number of fundamental problems that hundreds of engineers are working on:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Determinism:&lt;/strong&gt; Generative models are inherently random. Competitive gaming requires pixel-by-pixel repeatability of the result, which is difficult to achieve without fixing the LED. However, the development of more and more new approaches reduces randomness to a minimum.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Energy consumption:&lt;/strong&gt; inference certainly consumes a lot of energy. In mobile gaming and on portable devices (e.g. Steam Deck, Nintendo Switch) this is a critical limitation. But a lot of work is also being done in this direction, offering new options for optimizing models.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Backward compatibility:&lt;/strong&gt; As the computing requirements of new models grow, old GPUs lose their ability to perform them efficiently, which creates fragmentation of the user base. Here, rather, the result will depend on the speed of the emergence of generally accepted standards in development, since we are only at the beginning of the path.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  There has already been an aversion to technology in history. You just don't remember it. How has the industry digested past graphic revolutions?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;The controversies surrounding the introduction of AI rendering:&lt;/strong&gt;  from "fake frames" and "soap instead of graphics" to the fear of losing control over the visual result, are certainly very loud, but they are not something new to the industry. &lt;strong&gt;Virtually every fundamental change in rendering architecture over the past 25 years has encountered similar resistance before becoming a new standard&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Compute shaders vs. a regular pipeline (2001-2004)
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fajjjdhrzmsah6lhy6inh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fajjjdhrzmsah6lhy6inh.png" alt="The revolution of those years, which showed the advantages of frightening shader technologies" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Before the advent of GeForce 3 and DirectX 8&lt;/strong&gt;, the graphics pipeline was a rigidly defined chain of operations: vertex transformation, lighting using fixed formulas, rasterization, texture mixing. And then we were allowed to program our own vertex and pixel shaders for each stage, which opened the way to normal maps, dynamic shadows, and complex materials.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;At that time, people were afraid&lt;/strong&gt; that shaders were too slow, developers couldn't handle writing complex code, and that shaders that could be coded were crutches, not a step forward.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In reality, after just five years&lt;/strong&gt;, games without shaders have become a relic of the past. Half-Life 2, Doom 3, Far Cry have demonstrated that a programmable pipeline is not just a replacement for the old one, but a tool that allows you to create masterpieces that were previously impossible. Developers quickly mastered HLSL and GLSL, and performance increased due to hardware acceleration of shader blocks.&lt;/p&gt;

&lt;h3&gt;
  
  
  Transition to Deferred lighting (Deferred Rendering, 2007-2011)
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7cugii22be8fjcx3v59g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7cugii22be8fjcx3v59g.png" alt="Deferred Rendering - an industrial standart" width="800" height="342"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Classic forward rendering recalculated the lighting for each object&lt;/strong&gt;, which made multiple dynamic light sources impractical. &lt;strong&gt;Deferred rendering divided the process into two passes:&lt;/strong&gt; first, geometric attributes are written to the G‑buffer, and only then the lighting is calculated only in the screen space. This made it possible to use dozens and hundreds of dynamic light sources in the frame. But today it seems commonplace.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;But at that time, many argued&lt;/strong&gt; that the g-buffer would eat up a lot of memory, the powerful MSAA smoothing would have to be thrown in the trash, and all transparent objects would have to be replaced with something, because they break.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;But in reality, the industry found compromises&lt;/strong&gt;, because the pros outweighed all the cons. And so, instead of MSAA, new types of smoothing appeared first (FXAA, SMAA, later replaced by TAA and TAAU), which eventually even surpassed in quality. And the approach itself has become an industry standard.&lt;/p&gt;

&lt;h3&gt;
  
  
  Physically correct rendering (PBR, 2013-2016)
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl4ichztmkirgbtdvqwjv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl4ichztmkirgbtdvqwjv.png" alt="PBR Materials" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In the era before PBR&lt;/strong&gt;, materials were described by standard parameters (specular power, glossiness), which behaved differently in different lighting conditions and required manual adjustment to each scene. &lt;strong&gt;The physically correct approach introduced a unified BRDF model based on the measurable additional properties of real materials: metallic, roughness, albedo&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;However, at first, the reaction was harsh&lt;/strong&gt; - they said that all games would become the same and plastic, old textures would have to be redone from scratch, and artists would lose creative control.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;But something else happened:&lt;/strong&gt; PBR did not destroy the styling. He gave the artists a predictable foundation on top of which stylistic solutions can be applied. The transition to PBR, of course, required additional staff training and the introduction of new tools (such as Substance Painter, Quixel), but the result was a leap in realism and stability of materials between different scenes and projects. Today, even stylized cartoon games use a PBR pipeline adapted to aesthetics.&lt;/p&gt;

&lt;h3&gt;
  
  
  Today
&lt;/h3&gt;

&lt;p&gt;And now, starting in 2018, it all started with the transfer of raytracing technologies from film rendering to gaming. The first implementations were modest: only shadows or reflections with a low number of rays per pixel.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Seven years later, ray tracing has already become the standard in the AAA segment&lt;/strong&gt;. Cyberpunk 2077 in Path Tracing mode, Alan Wake 2, Black Myth: Wukong with full RT: these are examples of how the technology has matured and become a standard. Denoising and upscaling (including DLSS) have evolved to make RT playable. Current-generation consoles have received hardware RT blocks, and AMD and Intel are catching up with NVIDIA in tracing performance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The current transition to AI rendering shows all the same patterns as previous revolutions.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Is another revolution waiting for us? Let's summarize the results
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Each of the past revolutions took time to adapt, update the toolkit, train developers, and optimize hardware. AI rendering is no exception.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It does not cancel out the work of artists and programmers, but gives them a new level of abstraction: instead of manually dealing with noise, smoothing or optimizing materials, developers will be able to rely on models trained on huge data sets of photo-realistic or stylized content.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Moreover, as we have already seen above, history shows that after the adoption of a new paradigm or technology&lt;/strong&gt;, the industry does not just return to its previous level of quality, but enters a new stage. &lt;strong&gt;Shaders didn't kill 2D sprites&lt;/strong&gt;, but they gave us normal maps and dynamic shadows. &lt;strong&gt;PBR did not make the games monotonous&lt;/strong&gt;, but gave a new basis for both photo realism and stylization (for example, Dishonored 2).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;AI rendering will not destroy "classic" graphics&lt;/strong&gt;, but will allow for real-time visual complexity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Another question is how developers will use technology&lt;/strong&gt;, because there are examples where developers, even with a significant leap in technology, &lt;strong&gt;take a step back (hello Battlefield 6)&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The next five years will determine how much AI rendering will permeate every aspect of game creation&lt;/strong&gt;. Judging by the current trajectory, by 2030 the line between "rendering" and "generation" will become indistinguishable, or very blurred.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;So, thanks for reading!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I am waiting for your forecasts and ideas in the comments!&lt;/p&gt;

</description>
      <category>gamedev</category>
      <category>ai</category>
      <category>nvidia</category>
      <category>overview</category>
    </item>
    <item>
      <title>⚡Extremely Fast Way to Work with Binary Data - Flash Buffer for TypeScript</title>
      <dc:creator>Devs Daddy</dc:creator>
      <pubDate>Thu, 09 Apr 2026 13:06:39 +0000</pubDate>
      <link>https://forem.com/devsdaddy/extremely-fast-way-to-work-with-binary-data-flash-buffer-for-typescript-237p</link>
      <guid>https://forem.com/devsdaddy/extremely-fast-way-to-work-with-binary-data-flash-buffer-for-typescript-237p</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Speed ​​up binary I/O with zero-copy performance, automatic offset management, and a set of advanced tools.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Working with &lt;strong&gt;binary data in JavaScript and TypeScript&lt;/strong&gt; has always been a chore. Manually tracking offsets, worrying about endianness, and constantly copying memory—it's easy to get bogged down in boilerplate code. Existing libraries only address some of the issues, but they either tie to Node.js &lt;code&gt;Buffer&lt;/code&gt; or don't support modern features like &lt;code&gt;SharedArrayBuffer&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Today I'm excited to introduce &lt;a href="https://github.com/devsdaddy/flash-buffer/" rel="noopener noreferrer"&gt;Flash-Buffer&lt;/a&gt;: a lightning-fast binary data library that makes manipulating &lt;code&gt;ArrayBuffers&lt;/code&gt; as easy as working with JSON.&lt;/p&gt;




&lt;h2&gt;
  
  
  🤔 Problem: Binary data is complex and slow
&lt;/h2&gt;

&lt;p&gt;Whether you're parsing a custom network protocol, reading media file headers, or serializing game state for transmission over &lt;strong&gt;WebSocket&lt;/strong&gt;, you'll encounter the same inconveniences:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Manual offset management&lt;/strong&gt;. Every read or write requires updating the &lt;code&gt;offset&lt;/code&gt; variable. This is a source of infinite per-unit errors.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data copying&lt;/strong&gt;. Standard methods often create new buffers instead of working with existing ones. This &lt;strong&gt;kills performance&lt;/strong&gt; on large data sets.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lack of convenient abstractions&lt;/strong&gt;. You want to write a string or a floating-point number, but you have to fiddle with &lt;code&gt;DataView&lt;/code&gt; and &lt;code&gt;TextEncoder&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Flash-Buffer&lt;/strong&gt; solves these problems by providing an intuitive API that remains incredibly fast.&lt;/p&gt;




&lt;h2&gt;
  
  
  🚀 Key Features
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Zero-Copy&lt;/strong&gt;. Reading data returns a &lt;code&gt;Uint8Array&lt;/code&gt;, which is a direct "view" of the memory location. No unnecessary copying just pure performance.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Smart memory management&lt;/strong&gt;. Automatic buffer expansion on write (&lt;code&gt;exact&lt;/code&gt;, &lt;code&gt;powerOfTwo&lt;/code&gt;, &lt;code&gt;fixed&lt;/code&gt; strategies), built-in buffer pool to reduce GC load, native &lt;code&gt;resize()&lt;/code&gt; support for &lt;code&gt;ArrayBuffer&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cross-platform&lt;/strong&gt;. Works in browsers, Node.js, Deno, and Bun. Supports &lt;code&gt;SharedArrayBuffer&lt;/code&gt; for efficient data exchange between threads without copying.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Advanced data formats:&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;- &lt;strong&gt;VarInt&lt;/strong&gt; (LEB128) with ZigZag encoding-like &lt;strong&gt;Protobuf&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bitwise operations&lt;/strong&gt; (BitBuffer) for flags, compressed data, and cryptography.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;C-strings&lt;/strong&gt; (null-terminated).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stream adapters&lt;/strong&gt; for the Web Streams API.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Schematic serialization&lt;/strong&gt;. Use TypeScript decorators (&lt;code&gt;@field&lt;/code&gt;) to describe the class structure, and the library will automatically serialize it to and from a binary buffer.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  💻 Usage examples
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Basic reading and writing:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;FlashBuffer&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;flash-buffer&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Create a buffer (auto-growing, little-endian by default)&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;buf&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;FlashBuffer&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;endianness&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;little&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// Write data&lt;/span&gt;
&lt;span class="nx"&gt;buf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;writeUint32&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mh"&gt;0xDEADBEEF&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;buf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;writeString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello, Flash!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;utf-8&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// true = prefix length as uint32&lt;/span&gt;

&lt;span class="c1"&gt;// Reset the offset for reading&lt;/span&gt;
&lt;span class="nx"&gt;buf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reset&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// Read data back&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;buf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;readUint32&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;strLength&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;buf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;readUint32&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;str&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;buf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;readString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;strLength&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// 'deadbeef'&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;str&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;               &lt;span class="c1"&gt;// 'Hello, Flash!'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Working with VarInt (Variable-Length Integers):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;FlashBuffer&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;flash-buffer&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;buf&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;FlashBuffer&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// Write a large number (less than 128) in one byte instead of four&lt;/span&gt;
&lt;span class="nx"&gt;buf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;writeVarUint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;127&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Write a negative number efficiently using ZigZag encoding&lt;/span&gt;
&lt;span class="nx"&gt;buf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;writeVarInt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;buf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reset&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;buf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;readVarUint&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt; &lt;span class="c1"&gt;// 127&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;buf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;readVarInt&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;  &lt;span class="c1"&gt;// -15&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;buf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;offset&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;        &lt;span class="c1"&gt;// 3 (1 byte for 127 + 2 bytes for -15)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Bit-level operations:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;FlashBuffer&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;flash-buffer&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;buf&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;FlashBuffer&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;bits&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;buf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;bit&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// Write a sequence of bits that may cross byte boundaries&lt;/span&gt;
&lt;span class="nx"&gt;bits&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;writeBits&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mb"&gt;0b11111&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;bits&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;writeBits&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mb"&gt;0b10101&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;bits&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;flush&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// Important: flush to finalize the byte and align the offset&lt;/span&gt;

&lt;span class="nx"&gt;buf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reset&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;readBits&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;buf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;bit&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;readBits&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;readBits&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// 0b11111 (31)&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;readBits&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;readBits&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// 0b10101 (21)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Serializing objects using decorators:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;FlashBufferSchema&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;field&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;flash-buffer&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="cm"&gt;/* Create serializable class (Player) */&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Player&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;field&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;uint32&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;field&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;string&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;field&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;float32&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;field&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;float32&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="nx"&gt;y&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="cm"&gt;/* Create new Player */&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;player&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Player&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="nx"&gt;player&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;player&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;John&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;player&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;100.5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;player&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;200.5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="cm"&gt;/* Serialize and Restore Object */&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;buf&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;FlashBufferSchema&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;serialize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;player&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;restored&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;FlashBufferSchema&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;deserialize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Player&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;buf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reset&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  📊 Comparison with similar libraries
&lt;/h2&gt;

&lt;p&gt;Several excellent libraries exist for binary data manipulation. &lt;strong&gt;Flash Buffer&lt;/strong&gt; was designed to combine their strengths and offer unique capabilities.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;flash-buffer&lt;/th&gt;
&lt;th&gt;smart-buffer&lt;/th&gt;
&lt;th&gt;
&lt;a class="mentioned-user" href="https://dev.to/hazae41"&gt;@hazae41&lt;/a&gt;/binary&lt;/th&gt;
&lt;th&gt;@jsonjoy.com/buffers&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Zero-Copy&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;**SharedArrayBuffer**&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Automatic Growth&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Streaming (Web Streams)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Bit-Level Operations&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;VarInt (LEB128)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;C-Strings&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Schema Serialization&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Buffer Pool&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Unique advantages of Flash Buffer:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Full support&lt;/strong&gt; for &lt;code&gt;SharedArrayBuffer&lt;/code&gt; the key to copy-free multithreading.&lt;/li&gt;
&lt;li&gt;Modern &lt;code&gt;DataView&lt;/code&gt;-style API intuitive and concise.&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;wide range&lt;/strong&gt; of out-of-the-box tools: from VarInt to Serialization and streams.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  📦 Installation and getting started
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Just install via NPM (zero-dependency library):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;flash-buffer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Or clone from GitHub:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://github.com/devsdaddy/flash-buffer/" rel="noopener noreferrer"&gt;https://github.com/devsdaddy/flash-buffer/&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  💎 Conclusion
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://github.com/devsdaddy/flash-buffer/" rel="noopener noreferrer"&gt;Flash-Buffer&lt;/a&gt;&lt;/strong&gt; was created to free you from the pain of manually handling binary data. It combines the &lt;strong&gt;performance&lt;/strong&gt; of zero-copy, the convenience of high-level abstractions, and support for &lt;strong&gt;modern web standards&lt;/strong&gt;. If you write network protocols, parse files, or develop high-load services, try &lt;strong&gt;Flash-Buffer&lt;/strong&gt; and you'll be surprised at how simple binary code can be.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I welcome stars, issues, and pull requests on GitHub. Share your experiences or questions in the comments!&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>algorithms</category>
      <category>development</category>
      <category>resources</category>
    </item>
    <item>
      <title>A Post-Quantum Hybrid Encryption for High-Load Systems in TypeScript</title>
      <dc:creator>Devs Daddy</dc:creator>
      <pubDate>Mon, 06 Apr 2026 19:59:04 +0000</pubDate>
      <link>https://forem.com/devsdaddy/a-post-quantum-hybrid-encryption-for-high-load-systems-in-typescript-1lp6</link>
      <guid>https://forem.com/devsdaddy/a-post-quantum-hybrid-encryption-for-high-load-systems-in-typescript-1lp6</guid>
      <description>&lt;h2&gt;
  
  
  What is this post about?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbg86lju4ckq9pbxma1a5.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbg86lju4ckq9pbxma1a5.jpg" alt="QuarkDash Crypto" width="800" height="350"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This paper presents &lt;strong&gt;QuarkDash Crypto&lt;/strong&gt; (a quantum resistant hybrid encryption algorithm), an &lt;strong&gt;open-source TypeScript library&lt;/strong&gt; implementing a hybrid encryption protocol resistant to quantum computer attacks. &lt;strong&gt;QuarkDash&lt;/strong&gt; combines post-quantum key exchange based on &lt;strong&gt;Ring-LWE&lt;/strong&gt;, a fast stream cipher (&lt;strong&gt;ChaCha20&lt;/strong&gt; or &lt;strong&gt;Gimli&lt;/strong&gt;), a quantum-resistant &lt;strong&gt;KDF&lt;/strong&gt;, and a &lt;strong&gt;SHAKE256-based MAC&lt;/strong&gt;, as well as built-in mechanisms for protecting against replay and timing attacks.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Benchmark results are presented demonstrating throughput of up to &lt;code&gt;2.8 GB/s&lt;/code&gt; and session setup time of approximately &lt;code&gt;10 ms&lt;/code&gt;, which outperforms classical asymmetric schemes (&lt;code&gt;RSA&lt;/code&gt;, &lt;code&gt;ECC&lt;/code&gt;) and is comparable to symmetric encryption (&lt;code&gt;AES&lt;/code&gt;), but with additional quantum resistance.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you're not interested in the implementation details, you can skip straight to the &lt;a href="https://github.com/DevsDaddy/quarkdash" rel="noopener noreferrer"&gt;TypeScript library&lt;/a&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwlvcs0rvbitr5byp8r7g.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwlvcs0rvbitr5byp8r7g.webp" alt="Quantum resistant encryption - QuarkDash" width="800" height="509"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With the development of quantum computers, many widely used cryptographic algorithms (&lt;code&gt;RSA&lt;/code&gt;, &lt;code&gt;ECC&lt;/code&gt;, &lt;code&gt;DSA&lt;/code&gt;) are becoming vulnerable to &lt;strong&gt;Shor's&lt;/strong&gt; and &lt;strong&gt;Grover's&lt;/strong&gt; algorithms. In response, the cryptographic community is developing &lt;strong&gt;post-quantum cryptographic algorithms&lt;/strong&gt; (&lt;code&gt;PQC&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;However, implementing &lt;code&gt;PQC&lt;/code&gt; in real-world systems poses challenges: performance, key size, and compatibility. &lt;strong&gt;QuarkDash&lt;/strong&gt; addresses these issues by offering a &lt;strong&gt;hybrid approach&lt;/strong&gt;: post-quantum key encapsulation (using Ring-LWE) and high-performance symmetric encryption.&lt;/p&gt;

&lt;h2&gt;
  
  
  Selection of cryptographic primitives
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Post-quantum key exchange: Ring-LWE
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Ring-LWE (Ring Learning with Errors)&lt;/strong&gt; is one of the most studied candidates for the &lt;strong&gt;NIST PQC&lt;/strong&gt; finals. It is based on the difficulty of finding errors in a ring of integer polynomials. &lt;strong&gt;QuarkDash Crypto&lt;/strong&gt; uses the following parameters:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ring dimension &lt;code&gt;N = 256&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Modulus &lt;code&gt;Q = 7681&lt;/code&gt; (a prime number supporting fast NTT)&lt;/li&gt;
&lt;li&gt;Primitive root &lt;code&gt;ω = 7&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;These parameters provide &lt;strong&gt;128-bit post-quantum security&lt;/strong&gt; with compact keys (&lt;em&gt;public key ~2 KB&lt;/em&gt;, &lt;em&gt;private key ~1 KB&lt;/em&gt;). Polynomial multiplication is implemented using &lt;strong&gt;NTT (Number Theoretical Transform)&lt;/strong&gt; with complexity &lt;code&gt;O(N log N)&lt;/code&gt;, making key exchange very fast (&lt;strong&gt;~8 ms on modern processors&lt;/strong&gt;).&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  2. Symmetric Encryption: ChaCha20 and Gimli
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;For data encryption&lt;/strong&gt; after a session is established, &lt;strong&gt;QuarkDash Crypto&lt;/strong&gt; offers two stream ciphers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;ChaCha20&lt;/strong&gt; is a standardized (RFC 7539) high-performance cipher resistant to timing attacks. It uses &lt;code&gt;20 rounds&lt;/code&gt;, a &lt;code&gt;256-bit key&lt;/code&gt;, and a &lt;code&gt;12-byte nonce&lt;/code&gt;. Its software implementation is faster than AES without hardware acceleration.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Gimli&lt;/strong&gt; is a lightweight cipher designed for embedded systems. It uses &lt;code&gt;24 rounds&lt;/code&gt;, a &lt;code&gt;384-bit state&lt;/code&gt;, and provides &lt;code&gt;256-bit security&lt;/code&gt;. Gimli is faster than ChaCha20 on 32-bit architectures and requires less code.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2c9pt7isppt7zcv7p5nu.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2c9pt7isppt7zcv7p5nu.webp" alt="ChaCha20 in QuarkDash" width="800" height="638"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In my &lt;a href="https://github.com/DevsDaddy/quarkdash" rel="noopener noreferrer"&gt;TypeScript implementation&lt;/a&gt;, the choice of cipher is specified via configuration (&lt;code&gt;cipher: ChaCha20 | Gimli&lt;/code&gt;), which allows the library to be adapted to different platforms.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  3. Quantum-resistant KDF and MAC: SHAKE256
&lt;/h3&gt;

&lt;p&gt;For key &lt;strong&gt;derivation and authentication&lt;/strong&gt;, I use &lt;strong&gt;SHAKE256&lt;/strong&gt;, an extensible hash function based on the Keccak sponge that is resistant to quantum attacks. Since the Web Crypto API does not have built-in support for &lt;strong&gt;SHAKE256&lt;/strong&gt;, I emulate it by repeatedly calling SHA-256 in counter mode (which is sufficient for protocol purposes).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmsfp54jbmnlfyclvinq0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmsfp54jbmnlfyclvinq0.png" alt="MAC - QuarkDash Crypto" width="604" height="341"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So, it turns out that:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;KDF (Key Derivation Function):&lt;/strong&gt; takes a &lt;code&gt;shared secret (32 bytes)&lt;/code&gt;, a &lt;code&gt;salt (32 bytes)&lt;/code&gt;, and a &lt;code&gt;token&lt;/code&gt;, returning &lt;code&gt;64 bytes&lt;/code&gt; of &lt;code&gt;key material&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;MAC:&lt;/strong&gt; computed as &lt;strong&gt;SHAKE256(&lt;code&gt;macKey&lt;/code&gt; || &lt;code&gt;data&lt;/code&gt;, 32)&lt;/strong&gt;. Constant-time comparison is used.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. Protection against replay attacks
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Each encrypted message&lt;/strong&gt; contains a &lt;code&gt;12-byte header&lt;/code&gt;: a &lt;code&gt;timestamp&lt;/code&gt; (&lt;code&gt;8 bytes&lt;/code&gt;, Unix time in milliseconds) and a &lt;code&gt;sequence number&lt;/code&gt; (&lt;code&gt;4 bytes&lt;/code&gt;). During decryption, the following is checked:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;timestamp&lt;/code&gt; deviation does not exceed the specified value (5 minutes by default).&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;sequence number&lt;/code&gt; has not been repeated (a sliding window of the last 1000 packets is stored).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This prevents replay attacks both within a session and over long periods of time.&lt;/p&gt;




&lt;h2&gt;
  
  
  QuarkDash's Algorithm (Step-by-Step)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Long-Term Key Generation (Ring-LWE)
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Choose a &lt;strong&gt;random polynomial&lt;/strong&gt; a with coefficients from &lt;code&gt;Z_Q&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Choose &lt;strong&gt;small polynomials&lt;/strong&gt; &lt;code&gt;s&lt;/code&gt; (secret) and &lt;code&gt;e&lt;/code&gt; (error) with coefficients &lt;code&gt;{-1, 0, 1}&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Calculate &lt;code&gt;b = a ⊗ s + e&lt;/code&gt; (multiplication via NTT, addition coefficientwise).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Public key:&lt;/strong&gt; &lt;code&gt;(a, b)&lt;/code&gt;, private: &lt;code&gt;s&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  2. Session Establishment (KEM)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Initiator (for example, client):&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;- Receives &lt;strong&gt;Receiver's&lt;/strong&gt; public key &lt;code&gt;(a, b)&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;- Generates small &lt;code&gt;s'&lt;/code&gt;, &lt;code&gt;e'&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;- Computes &lt;code&gt;u = a ⊗ s' + e'&lt;/code&gt; (ciphertext).&lt;/li&gt;
&lt;li&gt;- Computes &lt;code&gt;w = b ⊗ s'&lt;/code&gt;, rounds the coefficients to bits → &lt;code&gt;sharedSecret&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;ul&gt;
&lt;li&gt;Sends &lt;code&gt;u&lt;/code&gt; to &lt;strong&gt;Receiver&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Receiver (for example, server):&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Using his secret &lt;code&gt;s&lt;/code&gt;, computes &lt;code&gt;w' = u ⊗ s&lt;/code&gt;, rounds → the same &lt;code&gt;sharedSecret&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Session Key Derivation (KDF)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;keyMaterial&lt;/code&gt; = &lt;strong&gt;SHAKE256(&lt;code&gt;salt&lt;/code&gt; || &lt;code&gt;sharedSecret&lt;/code&gt; || &lt;code&gt;"session-key"&lt;/code&gt;, 64)&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;sessionKey&lt;/code&gt; = &lt;code&gt;keyMaterial[0:32]&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;macKey&lt;/code&gt; = &lt;code&gt;keyMaterial[32:64]&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. Message encryption
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;For each message:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Generate &lt;code&gt;header = timestamp(8) || sequence(4)&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ciphertext = streamCipher.encrypt(plaintext)&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;mac = SHAKE256(macKey || header || ciphertext, 32)&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Send &lt;code&gt;header || ciphertext || mac&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  5. Decryption and verification
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Split into &lt;code&gt;header&lt;/code&gt;, &lt;code&gt;ciphertext&lt;/code&gt;, and &lt;code&gt;mac&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Check &lt;code&gt;mac&lt;/code&gt; (constant time).&lt;/li&gt;
&lt;li&gt;Check &lt;code&gt;timestamp&lt;/code&gt; (within the window).&lt;/li&gt;
&lt;li&gt;Check &lt;code&gt;sequence&lt;/code&gt; (not repeating).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;plaintext = streamCipher.decrypt(ciphertext)&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;What's it. This algorim provides very fast and secured encryption between two entities (for example, for realtime connection between client and server).&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Security
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxgfb6xopyn2je139uo41.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxgfb6xopyn2je139uo41.webp" alt="QuarkDash Crypto Security" width="800" height="457"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Post-quantum security
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ring-LWE&lt;/strong&gt; has no known quantum algorithms for efficiently solving it (unlike factorization or discrete logarithm).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SHAKE256&lt;/strong&gt; provides resistance to quantum attacks (unlike SHA-2, which can theoretically be weakened by &lt;code&gt;Grover's algorithm&lt;/code&gt;, but with less effect).&lt;/li&gt;
&lt;li&gt;The combination of &lt;strong&gt;Ring-LWE and SHAKE256&lt;/strong&gt; provides &lt;strong&gt;128-256-bit&lt;/strong&gt; security against both quantum and classical attacks.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Protection against side-channel attacks
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;All MAC comparisons are performed in constant time (&lt;code&gt;constantTimeEqual&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Keys are erased from memory (&lt;code&gt;secureZero&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;There are no branches on secret data in critical areas (&lt;code&gt;cipher&lt;/code&gt;, &lt;code&gt;KDF&lt;/code&gt;, &lt;code&gt;MAC&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Forward Secrecy
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Each session&lt;/strong&gt; uses ephemeral key exchange (via &lt;code&gt;KEM&lt;/code&gt;). Even if the server's long-term key is compromised, past sessions remain protected.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Replay Protection
&lt;/h3&gt;

&lt;p&gt;The built-in &lt;code&gt;timestamp&lt;/code&gt; and &lt;code&gt;sequence number&lt;/code&gt; prevent replay attacks within a specified time window.&lt;/p&gt;




&lt;h2&gt;
  
  
  Performance
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Below are the results of synthetic benchmarks in comparison with other popular algorithms.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Operation&lt;/th&gt;
&lt;th&gt;QuarkDash (ChaCha20)&lt;/th&gt;
&lt;th&gt;QuarkDash (Gimli)&lt;/th&gt;
&lt;th&gt;AES-256-GSM&lt;/th&gt;
&lt;th&gt;ECDH (P-256) + AES&lt;/th&gt;
&lt;th&gt;RSA-2048&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Key generation&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;12.3ms&lt;/td&gt;
&lt;td&gt;12.1ms&lt;/td&gt;
&lt;td&gt;N/A&lt;/td&gt;
&lt;td&gt;1.2ms&lt;/td&gt;
&lt;td&gt;48ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;Session&lt;/strong&gt; (KEM)&lt;/td&gt;
&lt;td&gt;8.7ms&lt;/td&gt;
&lt;td&gt;8.5ms&lt;/td&gt;
&lt;td&gt;N/A&lt;/td&gt;
&lt;td&gt;3.4ms&lt;/td&gt;
&lt;td&gt;42ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;Encryption&lt;/strong&gt; (1KB)&lt;/td&gt;
&lt;td&gt;0.003ms&lt;/td&gt;
&lt;td&gt;0.0028ms&lt;/td&gt;
&lt;td&gt;0.005ms&lt;/td&gt;
&lt;td&gt;0.05ms&lt;/td&gt;
&lt;td&gt;0.8ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;Decryption&lt;/strong&gt; (1KB)&lt;/td&gt;
&lt;td&gt;0.003ms&lt;/td&gt;
&lt;td&gt;0.0028ms&lt;/td&gt;
&lt;td&gt;0.005ms&lt;/td&gt;
&lt;td&gt;0.05ms&lt;/td&gt;
&lt;td&gt;0.1ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;Encryption&lt;/strong&gt; (1MB)&lt;/td&gt;
&lt;td&gt;0.42ms&lt;/td&gt;
&lt;td&gt;0.38ms&lt;/td&gt;
&lt;td&gt;0.85ms&lt;/td&gt;
&lt;td&gt;21ms&lt;/td&gt;
&lt;td&gt;102ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;Decryption&lt;/strong&gt; (1MB)&lt;/td&gt;
&lt;td&gt;0.42ms&lt;/td&gt;
&lt;td&gt;0.38ms&lt;/td&gt;
&lt;td&gt;0.85ms&lt;/td&gt;
&lt;td&gt;21ms&lt;/td&gt;
&lt;td&gt;1080ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;Speed&lt;/strong&gt; (MB/s)&lt;/td&gt;
&lt;td&gt;2300&lt;/td&gt;
&lt;td&gt;2630&lt;/td&gt;
&lt;td&gt;1176&lt;/td&gt;
&lt;td&gt;48&lt;/td&gt;
&lt;td&gt;0.9&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  Advantages of QuarkDash over other algorithms
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. AES (symmetric encryption) in comparison
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Quantum resistance&lt;/strong&gt; – AES is vulnerable to Grover's algorithm (brute-force attack speeds up by √N).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Built-in key exchange&lt;/strong&gt; – no pre-distribution of keys is required.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Forward secrecy&lt;/strong&gt; – compromising a long-term key does not reveal past sessions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Replay protection&lt;/strong&gt; – in AES, this must be implemented separately.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Faster when implemented in software&lt;/strong&gt; (QuarkDash is faster than AES without hardware acceleration).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. ECC (Asymmetric on Elliptic Curves) in comparison
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Quantum resistance&lt;/strong&gt; – Shor's algorithm breaks ECC in polynomial time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Better performance for large messages&lt;/strong&gt; – ECIES encrypts data using AES, but adds the overhead of ECDH.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Smaller packet size&lt;/strong&gt; – 44 bytes versus 61 bytes for ECIES.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Easier to implement&lt;/strong&gt; – ​​no need to check points on the curve or protect against subgroup attacks.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. RSA (asymmetric factorization) in comparison
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Quantum resistance&lt;/strong&gt; – RSA is broken by Shor's algorithm.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Huge performance gap&lt;/strong&gt; – RSA is 250+ times slower for encryption, 1000+ times slower for decryption.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Smaller keys&lt;/strong&gt; – No, RSA has a 256-byte key, while QuarkDash has 2 KB (but 256 bits of security versus 112 bits for RSA-2048).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No padding issues&lt;/strong&gt; – RSA requires complex OAEP, which is susceptible to oracle attacks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Linear scaling&lt;/strong&gt; – QuarkDash has O(n) complexity, while RSA has O(n³).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Characteristic comparison
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Characteristic&lt;/th&gt;
&lt;th&gt;QuarkDash (ChaCha20)&lt;/th&gt;
&lt;th&gt;QuarkDash (Gimli)&lt;/th&gt;
&lt;th&gt;AES-256-GSM&lt;/th&gt;
&lt;th&gt;ECDH/P-256 + AES&lt;/th&gt;
&lt;th&gt;RSA-2048 + AES&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Type&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Hybrid&lt;/td&gt;
&lt;td&gt;Hybrid&lt;/td&gt;
&lt;td&gt;Symmetric&lt;/td&gt;
&lt;td&gt;Asymmetric (KEX)&lt;/td&gt;
&lt;td&gt;Hybrid&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Quantum stability&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;✅ Ring-LWE&lt;/td&gt;
&lt;td&gt;✅ Ring-LWE&lt;/td&gt;
&lt;td&gt;❌ No&lt;/td&gt;
&lt;td&gt;❌ No&lt;/td&gt;
&lt;td&gt;❌ No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Encryption speed (1mb)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;~2.5 GB/s&lt;/td&gt;
&lt;td&gt;~2.8 GB/s&lt;/td&gt;
&lt;td&gt;~1.2 GB/s&lt;/td&gt;
&lt;td&gt;~50 MB/s (ECIES)&lt;/td&gt;
&lt;td&gt;~10 MB/s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Decryption speed (1mb)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;~2.5 GB/s&lt;/td&gt;
&lt;td&gt;~2.8 GB/s&lt;/td&gt;
&lt;td&gt;~1.2 GB/s&lt;/td&gt;
&lt;td&gt;~50 MB/s&lt;/td&gt;
&lt;td&gt;~1 MB/s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Session speed&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;~10-15 ms&lt;/td&gt;
&lt;td&gt;~10-15 ms&lt;/td&gt;
&lt;td&gt;0 ms (pre-shared)&lt;/td&gt;
&lt;td&gt;~5 ms&lt;/td&gt;
&lt;td&gt;~50 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Public key size&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;~2 KB&lt;/td&gt;
&lt;td&gt;~2 KB&lt;/td&gt;
&lt;td&gt;N/A&lt;/td&gt;
&lt;td&gt;33 bytes&lt;/td&gt;
&lt;td&gt;256 bytes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Private key size&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;~1 KB&lt;/td&gt;
&lt;td&gt;~1 KB&lt;/td&gt;
&lt;td&gt;N/A&lt;/td&gt;
&lt;td&gt;32 bytes&lt;/td&gt;
&lt;td&gt;256 bytes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Overhead size&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;44 bytes&lt;/td&gt;
&lt;td&gt;44 bytes&lt;/td&gt;
&lt;td&gt;28 bytes&lt;/td&gt;
&lt;td&gt;61 bytes&lt;/td&gt;
&lt;td&gt;256+ bytes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Forward secrecy&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;⚠️ optional&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Replay security&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Authentication&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;✅ MAC (SHAKE256)&lt;/td&gt;
&lt;td&gt;✅ MAC (SHAKE256)&lt;/td&gt;
&lt;td&gt;✅ (GSM)&lt;/td&gt;
&lt;td&gt;✅ (ECIES)&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Timing attacks security&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;✅ constant-time&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;⚠️ Partial&lt;/td&gt;
&lt;td&gt;⚠️ Partial&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;The Difficulty of Quantum Hacking&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;2^256&lt;/td&gt;
&lt;td&gt;2^256&lt;/td&gt;
&lt;td&gt;2^128 (Grover)&lt;/td&gt;
&lt;td&gt;0 (Shor)&lt;/td&gt;
&lt;td&gt;0 (Shor)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  QuarkDash Crypto installation and use cases for web apps
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Below I have provided an example of using the QuarkDash algorithm based on an &lt;a href="https://github.com/DevsDaddy/quarkdash" rel="noopener noreferrer"&gt;implementation I wrote in TypeScript&lt;/a&gt; that can be used in your web applications.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You can use the &lt;strong&gt;QuarkDash library&lt;/strong&gt; as a regular library for both Backend and Frontend applications without any additional dependencies.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Installation using NPM:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;quarkdash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Or using GitHub:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/devsdaddy/quarkdash
&lt;span class="nb"&gt;cd&lt;/span&gt; ./quarkdash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Basic example
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="cm"&gt;/* Import modules */&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;CipherType&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;QuarkDash&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;QuarkDashUtils&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;../src&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="cm"&gt;/* Alice - client, bob - server, for example for key-exchange */&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;alice&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;QuarkDash&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;cipher&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;CipherType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Gimli&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;bob&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;QuarkDash&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;cipher&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;CipherType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Gimli&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="cm"&gt;/* Generate key pair */&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;alicePub&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;alice&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;generateKeyPair&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;bobPub&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;bob&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;generateKeyPair&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="cm"&gt;/* Initialize session at bob and jpin alice public key */&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;ciphertext&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;alice&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;initializeSession&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;bobPub&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nb"&gt;Uint8Array&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;bob&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;initializeSession&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;alicePub&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;bob&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;finalizeSession&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ciphertext&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="cm"&gt;/* Encrypt by alice and decrypt by bob */&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;plain&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;QuarkDashUtils&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;textToBytes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello QuarkDash 🔒!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;enc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;alice&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encrypt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;plain&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;dec&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;bob&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;decrypt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;enc&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Decrypted:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;QuarkDashUtils&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;bytesToText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;dec&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;QuarkDash&lt;/strong&gt; is the first &lt;strong&gt;TypeScript library&lt;/strong&gt; that combines post-quantum key exchange &lt;strong&gt;(Ring-LWE)&lt;/strong&gt;, a fast stream cipher (based on ChaCha20/Gimli), and quantum-resistant &lt;strong&gt;KDF/MAC&lt;/strong&gt; (based on &lt;strong&gt;SHAKE256&lt;/strong&gt;) into a single &lt;strong&gt;hybrid protocol&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It is production-ready, features high performance (up to 2.8 GB/s), protection against side-channel and replay attacks, and provides a simple and extensible API.&lt;/p&gt;

&lt;p&gt;The library is available on &lt;a href="https://github.com/DevsDaddy/quarkdash/" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt; and &lt;a href="https://www.npmjs.com/package/quarkdash" rel="noopener noreferrer"&gt;npm&lt;/a&gt;. The source code is open-sourced under the MIT license. I invite the community to test, review, and contribute improvements.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Thanks for reading!&lt;/strong&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Useful Links:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://datatracker.ietf.org/doc/html/rfc7539" rel="noopener noreferrer"&gt;ChaCha Specification&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://gimli.cr.yp.to/" rel="noopener noreferrer"&gt;Gimli&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://people.csail.mit.edu/vinodv/6876-Fall2018/RingLWEclass.pdf" rel="noopener noreferrer"&gt;Ring-LWE&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/DevsDaddy/quarkdash/wiki" rel="noopener noreferrer"&gt;QuarkDash Documentation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>typescript</category>
      <category>security</category>
      <category>cryptography</category>
      <category>encryption</category>
    </item>
    <item>
      <title>[Boost]</title>
      <dc:creator>Devs Daddy</dc:creator>
      <pubDate>Mon, 02 Feb 2026 17:44:41 +0000</pubDate>
      <link>https://forem.com/devsdaddy/-374f</link>
      <guid>https://forem.com/devsdaddy/-374f</guid>
      <description>&lt;div class="ltag__link"&gt;
  &lt;a href="/neurosell" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__org__pic"&gt;
      &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Forganization%2Fprofile_image%2F10658%2F4a68ee38-a0dc-4b6e-ac60-d3b99492527d.jpg" alt="Neurosell" width="300" height="300"&gt;
      &lt;div class="ltag__link__user__pic"&gt;
        &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1403472%2F2bd65618-32b2-4139-a698-7a2e75574534.jpeg" alt="" width="460" height="460"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/neurosell/neurosell-became-the-organizer-and-sponsor-of-the-ai-pulse-2026-conference-in-perm-374h" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;Neurosell became the organizer and sponsor of the AI Pulse 2026 conference in Perm&lt;/h2&gt;
      &lt;h3&gt;Devs Daddy for Neurosell ・ Feb 2&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#ai&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#conference&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#machinelearning&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#community&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


</description>
      <category>ai</category>
      <category>conference</category>
      <category>machinelearning</category>
      <category>community</category>
    </item>
    <item>
      <title>Neurosell became the organizer and sponsor of the AI Pulse 2026 conference in Perm</title>
      <dc:creator>Devs Daddy</dc:creator>
      <pubDate>Mon, 02 Feb 2026 17:44:25 +0000</pubDate>
      <link>https://forem.com/neurosell/neurosell-became-the-organizer-and-sponsor-of-the-ai-pulse-2026-conference-in-perm-374h</link>
      <guid>https://forem.com/neurosell/neurosell-became-the-organizer-and-sponsor-of-the-ai-pulse-2026-conference-in-perm-374h</guid>
      <description>&lt;p&gt;On January 30, the startup Neurosell became one of the organizers and sponsors of the first AI conference in 2026—AI Pulse in Perm. The conference brought together more than 200 participants from leading companies in Russia and the CIS, as well as hundreds of online participants. More than 25 presentations were given, and there was an extensive networking program, an expo zone, and much more.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conference guests
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl2zkb9pfkjjabx0jn9l5.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl2zkb9pfkjjabx0jn9l5.jpg" alt="AI Pulse 2026 - Plati po Miru, Pavel Belov" width="800" height="533"&gt;&lt;/a&gt;&lt;br&gt;
The event was attended by representatives of more than 150 different companies, including TON Foundation, Ozon, Selectel, AllSee, AiDee, Neurosell, Timeweb Cloud, School 21, and other industry leaders.&lt;/p&gt;

&lt;p&gt;The conference opened with a heated discussion on the future of artificial intelligence, with experts from the Ministry of Digital Development of the Perm Region, the Federation Council, and companies such as Reactive, Spectr, Neurosell, neuromus, Wikibot, and Plati po Miru.&lt;/p&gt;

&lt;h2&gt;
  
  
  What else did the program include?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3v8no0bw68j6603e3kme.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3v8no0bw68j6603e3kme.jpg" alt="AI Pulse 2026 - Wikibot, Alex Skakovsky" width="800" height="533"&gt;&lt;/a&gt;&lt;br&gt;
The program also featured two sessions of presentations: one for businesses and one for developers, an exhibition of solutions from startups and companies, over 11 hours of networking, prize draws, and an official party for speakers and VIP guests.&lt;/p&gt;

&lt;h2&gt;
  
  
  What were the key points of the conference?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj6in2hfjtprkbl1rlcsj.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj6in2hfjtprkbl1rlcsj.jpg" alt="AI Pulse 2026" width="800" height="533"&gt;&lt;/a&gt;&lt;br&gt;
In addition to active networking and heated discussions about the upcoming challenges and prospects for artificial intelligence in 2026, more serious topics were increasingly raised at the conference, such as changes in fundamental AI technologies (replacing classic LLM), optimization of classic LLM models, increasing business automation, but at the same time more conscious use of AI in all aspects of life.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For more details, please see the recordings of the presentations, which will be available on the AI Pulse 2026 conference website in the coming days:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://aipls.ru/" rel="noopener noreferrer"&gt;https://aipls.ru/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The conference was organized by:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Morion Digital High-Tech Park;&lt;/li&gt;
&lt;li&gt;AI Hub Artificial Intelligence Community;&lt;/li&gt;
&lt;li&gt;Neurosell;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh0jqazhc3eutl0x4h5r2.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh0jqazhc3eutl0x4h5r2.jpg" alt="AI Pulse 2026" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The next conference is scheduled for August this year and will be even larger in scale.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>conference</category>
      <category>machinelearning</category>
      <category>community</category>
    </item>
    <item>
      <title>Neurosell won the award - best startup of the week with Virton AI product</title>
      <dc:creator>Devs Daddy</dc:creator>
      <pubDate>Mon, 26 May 2025 10:31:25 +0000</pubDate>
      <link>https://forem.com/neurosell/neurosell-won-the-award-best-startup-of-the-week-with-virton-ai-product-2dhc</link>
      <guid>https://forem.com/neurosell/neurosell-won-the-award-best-startup-of-the-week-with-virton-ai-product-2dhc</guid>
      <description>&lt;p&gt;Today, &lt;strong&gt;Neurosell&lt;/strong&gt; shared the win for Startup of the Week by &lt;strong&gt;Product Radar&lt;/strong&gt;. Let's find out how it happened and what results it yielded.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why did Neurosell enter the competition?
&lt;/h2&gt;

&lt;p&gt;The flagship product of startup &lt;strong&gt;Neurosell&lt;/strong&gt; is AI-powered virtual fitting rooms. The team has great expertise in development, including in AI organization. The &lt;strong&gt;Virton AI startup&lt;/strong&gt; is already working with pilot projects and testing many hypotheses, weekly algorithms. &lt;strong&gt;So why being an already growing startup - Virton AI was sent to the competition?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk8vk2l3f3obqjw570yq2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk8vk2l3f3obqjw570yq2.png" alt="Virton AI - Use cases" width="800" height="379"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;First and foremost&lt;/strong&gt; - the company enters contests to get expert feedback and community involvement. For Virton AI it is important to get not only customer experience, but also support and feedback from industry experts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Alexander Khopyorsky&lt;/strong&gt; - Founder at &lt;strong&gt;Brat AI&lt;/strong&gt;, no code for AI Agent - became the project hunter. Including the exchange of experience with other industry representatives is an important point in the formation of the company's product strategy.&lt;/p&gt;




&lt;h3&gt;
  
  
  What did the Virton AI team get out of the competition?
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;First and foremost, our team gained experience with the community. It was important for us to get feedback both from other founders in related fields and to learn more about working with communities like Product Radar. Such experience helps us adjust our product strategy and internal processes. - Elijah Rastorugev, Neurosell &amp;amp; Virton AI CTO&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foojs46nq9itejrcvzwbt.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foojs46nq9itejrcvzwbt.jpg" alt="Virton AI has 3000+ daily active users" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Naturally, this is just the beginning of the journey for Virton AI, but already, after just one month of an active public beta, the team has secured many key partners, including pilot projects with various brands.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;To learn more about Virton AI, visit the product's website:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://virton.tech/en/" rel="noopener noreferrer"&gt;https://virton.tech/en/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>startup</category>
      <category>virton</category>
      <category>news</category>
    </item>
    <item>
      <title>Neurosell shared new Virton AI successes and new brand partnerships</title>
      <dc:creator>Devs Daddy</dc:creator>
      <pubDate>Thu, 22 May 2025 13:33:06 +0000</pubDate>
      <link>https://forem.com/devsdaddy/neurosell-shared-new-virton-ai-successes-and-new-brand-partnerships-3mbe</link>
      <guid>https://forem.com/devsdaddy/neurosell-shared-new-virton-ai-successes-and-new-brand-partnerships-3mbe</guid>
      <description>&lt;p&gt;In today's weekly digest, Neurosell shares new successes and partnerships with apparel brands, IT integrators, and other company news.&lt;/p&gt;

&lt;h2&gt;
  
  
  Integrations with new brands and examples of Virton working as a cross-platform solution
&lt;/h2&gt;

&lt;p&gt;One of the major &lt;strong&gt;Virton AI&lt;/strong&gt; collaboration announcements among fashion companies was the launch of a pilot with premium clothing brand &lt;strong&gt;&lt;a href="https://de-backers.com/" rel="noopener noreferrer"&gt;DeBacker's&lt;/a&gt;&lt;/strong&gt;. The brand integrated with a fitting room based on Shopify, which is the first such integration.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F46bqqbjotnn84yehzxcv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F46bqqbjotnn84yehzxcv.png" alt="DeBacker's Integrated Virton AI in beta" width="800" height="569"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now the Neurosell team is actively working on other integration options, including Telegram and VK mini-apps. Examples of such integrations can be seen below:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://vk.com/app53582865" rel="noopener noreferrer"&gt;DSM Icons Brand at VK Mini Apps&lt;/a&gt;;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://t.me/vrtn_bot/nash_los" rel="noopener noreferrer"&gt;NashLocь - Virtual fitting room in Telegram Mini Apps&lt;/a&gt;;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These integrations with new sales channels for an apparel brand can be up and running in a single day, which is one of the benefits of going full-fledged with &lt;strong&gt;Virton AI&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Participating in the battle of startups on Product Radar
&lt;/h2&gt;

&lt;p&gt;Also this week, &lt;strong&gt;Neurosell&lt;/strong&gt; began competing in a battle for the title of Startup of the Week and Month on the &lt;strong&gt;Product Radar&lt;/strong&gt; platform with &lt;strong&gt;Virton AI&lt;/strong&gt;. The project hunter was &lt;strong&gt;Alexander Khopyorsky&lt;/strong&gt;, founder of &lt;strong&gt;Brat AI&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;You can vote for Virton AI on the Product Radar page:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://productradar.ru/product/virton/" rel="noopener noreferrer"&gt;https://productradar.ru/product/virton/&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  New records and Virton AI users
&lt;/h2&gt;

&lt;p&gt;Well, the latest news from Neurosell is that Virton AI's daily user traffic grew over 100% this week to over &lt;strong&gt;3,000 daily users&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The product is currently in training and in collaboration with brands to develop its algorithms.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;More details can be found on the Virton AI website:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://virton.tech/" rel="noopener noreferrer"&gt;https://virton.tech/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>startup</category>
      <category>news</category>
      <category>virton</category>
    </item>
    <item>
      <title>Neurosell announces new product - marketplace based on Virton AI fitting room, talks about updates and new partnerships</title>
      <dc:creator>Devs Daddy</dc:creator>
      <pubDate>Sun, 18 May 2025 16:30:43 +0000</pubDate>
      <link>https://forem.com/neurosell/neurosell-announces-new-product-marketplace-based-on-virton-ai-fitting-room-talks-about-updates-466k</link>
      <guid>https://forem.com/neurosell/neurosell-announces-new-product-marketplace-based-on-virton-ai-fitting-room-talks-about-updates-466k</guid>
      <description>&lt;p&gt;The other day, Neurosell, a startup developing Virton AI-based virtual fitting rooms, talked about Virton's upcoming updates, including the launch of a marketplace based on current services, as well as new pilot projects.&lt;/p&gt;

&lt;h2&gt;
  
  
  Virton AI-powered martkeplaces announced
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhiueses0f01w0b1vls3n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhiueses0f01w0b1vls3n.png" alt="Virton AI" width="800" height="384"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Today Neurosell announced a new product - &lt;strong&gt;a marketplace based on Virton AI&lt;/strong&gt;. This functionality will work in parallel with the usual fitting rooms, but in addition to the usual fitting rooms, a marketplace based on applications for Google Play, Android, as well as VK Mini Apps and Telegram Mini Apps will be launched.&lt;/p&gt;

&lt;p&gt;Every store that connects a fitting room will immediately be placed in the marketplace, thus opening up a new audience for Virton. &lt;strong&gt;The marketplace is scheduled to launch in June 2025.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Virton AI analytical tools
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwxvqy34cye6hv3ybw2mo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwxvqy34cye6hv3ybw2mo.png" alt="Virton AI" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Advanced analytics will be available to all &lt;strong&gt;Virton AI&lt;/strong&gt; users in the coming weeks. This will include an overview of popular products, a look at the number of generations, generation of picks based on product popularity, and an overview of the audience cross-section, including a breakdown by day.&lt;/p&gt;

&lt;p&gt;Already now, there is functionality to track UTM fitting room tags, which are generated automatically for each product.&lt;/p&gt;




&lt;h2&gt;
  
  
  New pilot projects and partners
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6ba2mof0is0vd63xg2zs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6ba2mof0is0vd63xg2zs.png" alt="Virton AI" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Neurosell&lt;/strong&gt; has also announced partnerships for &lt;strong&gt;Virton AI&lt;/strong&gt; virtual fitting room pilots with brands such as Nishtyak Bratok, Zanovo, Murka, NashLosь, DSM Icons, Knives and other apparel brands. This helps in training the neural network even faster and better. Pilot projects are planned for six months, during which time the &lt;strong&gt;generation quality is expected to improve by more than 90%&lt;/strong&gt;.&lt;/p&gt;




&lt;p&gt;More detailed information is always available on the &lt;strong&gt;official Virton AI website&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://virton.tech/" rel="noopener noreferrer"&gt;https://virton.tech/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>news</category>
      <category>virton</category>
    </item>
    <item>
      <title>Neurosell launched a major update to Virton AI and talk about future development plans</title>
      <dc:creator>Devs Daddy</dc:creator>
      <pubDate>Sat, 10 May 2025 16:17:24 +0000</pubDate>
      <link>https://forem.com/devsdaddy/neurosell-launched-a-major-update-to-virton-ai-and-talk-about-future-development-plans-50p9</link>
      <guid>https://forem.com/devsdaddy/neurosell-launched-a-major-update-to-virton-ai-and-talk-about-future-development-plans-50p9</guid>
      <description>&lt;p&gt;Hi everyone, we're here with &lt;a href="https://neurosell.top/" rel="noopener noreferrer"&gt;&lt;strong&gt;Neurosell&lt;/strong&gt;&lt;/a&gt;. Today we're going to talk about the past week's progress, including the launch of the new &lt;strong&gt;Virton AI&lt;/strong&gt; update, development plans for the near future and new partner destinations.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;This is gonna be interesting, let's go!&lt;/strong&gt;
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Virton AI's massive new update
&lt;/h2&gt;

&lt;p&gt;Today we launched a major new update to our artificial intelligence-based virtual fitting rooms - Virton AI. It includes new functionality for online store owners, updated algorithms for working with photos, widgets and internal tests of video fitting in motion. Below, we tell you about everything in order.&lt;/p&gt;

&lt;h3&gt;
  
  
  Online Store Dashboard
&lt;/h3&gt;

&lt;p&gt;Started a personal store management cabinet to implement a fitting room widget without programming knowledge. To do this, you only need to customize the widget appearance, fill in the products and connect the widget to the site.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg5nmnkpluenepos02dyr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg5nmnkpluenepos02dyr.png" alt="Virton AI"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You don't need to fully customize products like in regular catalogs of online stores - you only need to customize the product photo, name and link for purchase, specifying categories.&lt;/p&gt;

&lt;p&gt;Appearance can be adjusted to your site - upload logos, adjust the color palette. Changed your site design? No problem - the widget automatically updates all settings when you save them in your control panel.&lt;/p&gt;

&lt;p&gt;![Virton AI](&lt;a href="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t9gfbsc2jv7lvg8vgjfb.png" rel="noopener noreferrer"&gt;https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t9gfbsc2jv7lvg8vgjfb.png&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Virton AI virtual fitting room algorithm update
&lt;/h3&gt;

&lt;p&gt;We've also updated our algorithms, making them even more accurate for trying on products. And the fitting widget itself has become clearer, more user-friendly and simpler.&lt;/p&gt;

&lt;p&gt;In addition, we have internally tested the &lt;strong&gt;online fitting room algorithm based on video in motion&lt;/strong&gt;. The result of the video sample from the internal tests can be seen in this video:&lt;/p&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/dRyV9XV4T4Y"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;The launch of new algorithms for fitting accessories, hats, shoes by photo is planned for June, but with video fitting - we plan to start in August. If you have your own online store, right now you can join us on preferential terms (the first months are free), and then be one of the first to receive priority updates.&lt;/p&gt;




&lt;h2&gt;
  
  
  Neurosell and Virton AI partnership areas
&lt;/h2&gt;

&lt;p&gt;Starting Monday, &lt;strong&gt;Neurosell&lt;/strong&gt; will begin working with partners like &lt;strong&gt;Shopify&lt;/strong&gt;, &lt;strong&gt;InSales&lt;/strong&gt; and other online store building platforms to make it quick and easy for anyone to build full product card integration into their website.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Futp3vxircqfzh4szrkjq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Futp3vxircqfzh4szrkjq.png" alt="Virton AI"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In addition, we can already now individually connect the fitting room to your VK community or Telegram bot.&lt;/p&gt;




&lt;h2&gt;
  
  
  Pilot programs and new integrations
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Virton AI&lt;/strong&gt; is scheduled to roll out next week as pilot projects with 8+ apparel brands who will help train the algorithm at a discounted rate. For now, anyone can test our algorithms unlimitedly by installing the widget for free:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp2v6ldkw31bdpaoohhze.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp2v6ldkw31bdpaoohhze.png" alt="Virton AI Pricing"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As a final note, I'd like to extend a huge thank you for the support of all the apparel brands who are helping with the development of Virton AI, as well as the Neurosell team for their prompt work on the algorithm.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://virton.tech/en/" rel="noopener noreferrer"&gt;&lt;strong&gt;Try Virton AI for free&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;See you in a week!&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>startup</category>
      <category>product</category>
      <category>news</category>
    </item>
    <item>
      <title>Neurosell announces $800K seed round of investment to refine and scale Virton AI - fitting rooms for online stores</title>
      <dc:creator>Devs Daddy</dc:creator>
      <pubDate>Tue, 29 Apr 2025 11:10:41 +0000</pubDate>
      <link>https://forem.com/neurosell/neurosell-announces-800k-seed-round-of-investment-to-refine-and-scale-virton-ai-fitting-rooms-2bb8</link>
      <guid>https://forem.com/neurosell/neurosell-announces-800k-seed-round-of-investment-to-refine-and-scale-virton-ai-fitting-rooms-2bb8</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmlrubyx8dxfcrbr2ykrx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmlrubyx8dxfcrbr2ykrx.png" alt="Virton AI - Seed investment request announce" width="800" height="448"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Today, the Neurosell team is announcing the launch of the next round of Seed investment of $800,000 to improve the product and scale it to market. To date, the company has already raised $60,000 Pre-Seed investment for initial hypothesis tests.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's the plan to do?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fycqapzjjwikzrvrk019q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fycqapzjjwikzrvrk019q.png" alt="Virton AI - Seed investment request announce" width="800" height="449"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In addition to expanding the development team and launching marketing campaigns, Neurosell plans to take the accuracy of the algorithms to the next level, providing a new quantum leap.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key product readiness criteria based on Seed round highlighted for Virton AI:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Increase in generation speed by more than 115% - to an acceptable 5-6 seconds;&lt;/li&gt;
&lt;li&gt;Improving generation quality and its average rating up to 90%;&lt;/li&gt;
&lt;li&gt;Provision of tariff plans for businesses;&lt;/li&gt;
&lt;li&gt;Expansion of generation options in new projections (back, side, etc.);&lt;/li&gt;
&lt;li&gt;Expansion of supported product categories (shoes, jewelry, hats, etc. will be added);&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It is worth noting that Virton AI is part of Neurosell's ecosystem of products, which allows it to have big data to learn from e-commerce partners. Also, in the coming days, the company plans to launch a personal account for businesses, allowing them to create widgets and integrations for any online store in a few minutes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;You can follow Virton AI news in the official resources:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://blog.nsell.tech/" rel="noopener noreferrer"&gt;Neurosell Blog&lt;/a&gt;;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.crunchbase.com/organization/neurosell" rel="noopener noreferrer"&gt;Crunchbase Page&lt;/a&gt;;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://t.me/neuroselltothemoon" rel="noopener noreferrer"&gt;Neurosell Telegram Channel&lt;/a&gt;;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://bsky.app/profile/neurosell.bsky.social" rel="noopener noreferrer"&gt;Bluesky Profile&lt;/a&gt;;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ecommerce</category>
      <category>ai</category>
      <category>investment</category>
      <category>fashion</category>
    </item>
    <item>
      <title>Neural Network training on the example of Virton's virtual fitting room</title>
      <dc:creator>Devs Daddy</dc:creator>
      <pubDate>Wed, 23 Apr 2025 10:35:33 +0000</pubDate>
      <link>https://forem.com/devsdaddy/neural-network-training-on-the-example-of-virtons-virtual-fitting-room-55j2</link>
      <guid>https://forem.com/devsdaddy/neural-network-training-on-the-example-of-virtons-virtual-fitting-room-55j2</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Hi everyone, we are here with the &lt;strong&gt;Neurosell team&lt;/strong&gt;. In today's article we would like to share our experience in training neural networks on the example of our product - &lt;a href="https://virton.tech/" rel="noopener noreferrer"&gt;Virton&lt;/a&gt; virtual fitting room. We will tell you about the complexities of the algorithm, user experience and training opportunities.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fesn6a73847s58e4g656z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fesn6a73847s58e4g656z.png" alt="AI Training - Virton Examples" width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;First things first, let's review what our goals were:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Maximum preservation of context to get an accurate result of fitting in the image (for example, the user wants to match a T-shirt to his shorts in style;&lt;/li&gt;
&lt;li&gt;Accurate product image transfer with preserving poses, adding details of fabric folds, etc;&lt;/li&gt;
&lt;li&gt;Relative economy of algorithms;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What do we use for training and work?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;UNet-based generative and reference models;&lt;/li&gt;
&lt;li&gt;PyTorch under the hood, transformers and diffusers;&lt;/li&gt;
&lt;li&gt;SCHP for pose detection and correction;&lt;/li&gt;
&lt;li&gt;DensePose for body pixelization;&lt;/li&gt;
&lt;li&gt;NVidia Cuda-based servers;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now that we have a quick look at the goals and technologies, let's break down what we are doing to train the algorithms, looking at the main challenges and current results.&lt;/p&gt;




&lt;h2&gt;
  
  
  Training algorithms, metrics in current format
&lt;/h2&gt;

&lt;p&gt;Initial training of the algorithms was performed on the large **DeepFashion **database, which offers many variations of different fashion items. Other sources for pose detection were also used. However, there is a disadvantage in using such databases - they do not provide real user experience and train models in ideal conditions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8upwax8xma9qqow2x75d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8upwax8xma9qqow2x75d.png" alt="Virton - Virtual AI fitting rooms" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What to do in such a case? Run beta versions of the algorithms!&lt;/strong&gt;&lt;br&gt;
As a result, real users start trying on clothes, creating new generations and pre-training the algorithm. And in the case of pilot products on online stores, we can make the algorithm even better, getting new styles, different users with their own understanding of how the services work.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So, what we have achieved in two weeks of training the algorithms:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;At launch and in the first week of operation - &lt;strong&gt;generation accuracy was in the neighborhood of 30%&lt;/strong&gt;;&lt;/li&gt;
&lt;li&gt;On the second week of work, some correction of UX and internal algorithms - &lt;strong&gt;the accuracy increased to 60%&lt;/strong&gt;;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Thus, by pre-training the algorithms on real users we bring the results to commercial values and this is only for 2 weeks of work.&lt;/p&gt;




&lt;h2&gt;
  
  
  What affects the accuracy of an algorithm?
&lt;/h2&gt;

&lt;p&gt;Under ideal conditions, of course, we get great results, but in the real world it doesn't work that way. We get different users who often take photos that are not quite right for the neural network to work. And all of this has to be taken into account.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvtr4cqbaz5r3dk680nmf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvtr4cqbaz5r3dk680nmf.png" alt="Virton AI" width="800" height="577"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In our case, accuracy is affected by:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The quality of the original photos;&lt;/li&gt;
&lt;li&gt;Compliance with color rules (if the person in the photo starts to merge with the background, or if he or she has monochromatic clothes that are difficult to segment);&lt;/li&gt;
&lt;li&gt;Presence of other people in the frame;&lt;/li&gt;
&lt;li&gt;Using photos that are not full-length;&lt;/li&gt;
&lt;li&gt;Posing (crossed legs, arms, etc.);&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The more of these indicators are combined together, the lower the quality of generation becomes. What to do in this case:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;First work through the UX and explain to the user in clear language under what conditions they might have a bad result;&lt;/li&gt;
&lt;li&gt;Do-train models on segmentation in various non-ideal poses for the algorithm;&lt;/li&gt;
&lt;li&gt;Implement Multi-View Pose Transfer (for sideways photos and other body rotations;&lt;/li&gt;
&lt;li&gt;Implement body part intersection detection, e.g. using pose detection algorithms (there are good examples on Tensorflow) and alert the user to problems;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Generation examples - from successes to epic fails
&lt;/h2&gt;

&lt;p&gt;And as the final block of this article - we decided to share with you the results of generation, among which there are excellent, and there are quite funny and even strange.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe48nrefno91and83iib9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe48nrefno91and83iib9.png" alt="Viron AI - Fitting Room Good Examples" width="800" height="445"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxeayoiq9bwqxd13g9npm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxeayoiq9bwqxd13g9npm.png" alt="Viron AI - Fitting Room Good Examples" width="800" height="445"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd2xqvsv4wscckjrrtlgi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd2xqvsv4wscckjrrtlgi.png" alt="Viron AI - Fitting Room Good Examples" width="800" height="445"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq6kjrkn5v1rymfwlbz82.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq6kjrkn5v1rymfwlbz82.png" alt="Fitting Room Bad Examples" width="800" height="445"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvwo24wf20qnebjver9nn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvwo24wf20qnebjver9nn.png" alt="Fitting Room Bad Examples" width="800" height="445"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;What I would like to summarize in the end: any neural networks trained on ideal data and various open databases, as a rule, do not take into account the user factor, which definitely affects the result. Therefore, it is worthwhile to densely engage in pre-training of models on your real users, work with UX and look for new options to improve algorithms (for example, by introducing new additional tools).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;And as always, discussions and your questions are welcome!&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>case</category>
      <category>development</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
