<?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: mohammad rostami</title>
    <description>The latest articles on Forem by mohammad rostami (@mohammad_rostami_).</description>
    <link>https://forem.com/mohammad_rostami_</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%2F3628004%2F2099a6d6-913c-4088-ba3c-9b587f8b8fd4.jpg</url>
      <title>Forem: mohammad rostami</title>
      <link>https://forem.com/mohammad_rostami_</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/mohammad_rostami_"/>
    <language>en</language>
    <item>
      <title>Technical Deep Dive: How React Server Components Work and Where the Vulnerabilities Appear</title>
      <dc:creator>mohammad rostami</dc:creator>
      <pubDate>Mon, 15 Dec 2025 20:42:52 +0000</pubDate>
      <link>https://forem.com/mohammad_rostami_/technical-deep-dive-how-react-server-components-work-and-where-the-vulnerabilities-appear-po6</link>
      <guid>https://forem.com/mohammad_rostami_/technical-deep-dive-how-react-server-components-work-and-where-the-vulnerabilities-appear-po6</guid>
      <description>&lt;p&gt;Hi everyone&lt;br&gt;
In a recent, I examined CVE-2025-55182, a critical vulnerability in React Server Components caused by an unsafe deserialization path that could lead to unauthenticated remote code execution. That issue highlighted how deeply framework internals can influence the security posture of applications built on top of them.&lt;/p&gt;

&lt;p&gt;Shortly after that disclosure, an additional set of security vulnerabilities was published affecting the same architectural layer in React Server Components (RSC) and Next.js. While these issues do not result in immediate remote code execution, they introduce significant risks, including Denial of Service (DoS) and unintended exposure of server-side source code and internal implementation details under specific conditions.&lt;/p&gt;

&lt;p&gt;This article builds on that context and focuses on the underlying execution model of React Server Components, explaining how these issues emerge at the framework level and why they matter for production deployments.&lt;/p&gt;

&lt;p&gt;To understand why the recently disclosed issues in React Server Components (RSC) lead to Denial of Service and source code exposure, it helps to look at how the RSC execution pipeline actually works on the server.&lt;/p&gt;
&lt;h2&gt;
  
  
  React Server Components: Server-Side Execution Flow
&lt;/h2&gt;

&lt;p&gt;A simplified but accurate RSC request lifecycle looks like this:&lt;/p&gt;
&lt;h2&gt;
  
  
  1 - Incoming request reaches the RSC endpoint
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;In Next.js, this typically maps to an internal route such as /_rsc&lt;/li&gt;
&lt;li&gt;The request is processed before authentication and before application middleware&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  2 - Request body parsing and protocol decoding
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The payload is parsed according to the React Flight protocol&lt;/li&gt;
&lt;li&gt;This includes decoding serialized component references, props, and execution hints&lt;/li&gt;
&lt;li&gt;At this stage, React assumes the payload shape is valid enough to be processed&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  3 - Component graph reconstruction
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;React reconstructs the Server Component tree from the serialized input&lt;/li&gt;
&lt;li&gt;Module references are resolved and loaded&lt;/li&gt;
&lt;li&gt;Async boundaries and Suspense segments are registered&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  4 - Server rendering and streaming
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Components are executed on the server&lt;/li&gt;
&lt;li&gt;Output is serialized again and streamed back to the client in chunks&lt;/li&gt;
&lt;li&gt;Error boundaries and partial results are flushed incrementally&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  5 - Error and recovery
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;If an exception occurs mid-stream, React attempts to recover gracefully&lt;/li&gt;
&lt;li&gt;Metadata, stack traces, and module identifiers are still available internally&lt;/li&gt;
&lt;li&gt;Each of these phases is sensitive to malformed or adversarial input.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  How Denial of Service Is Triggered
&lt;/h2&gt;

&lt;p&gt;The DoS issue arises primarily in steps 2 and 3, before any application logic is involved.&lt;br&gt;
A malicious request can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Inflate the serialized payload size&lt;/li&gt;
&lt;li&gt;Introduce deeply nested or cyclic references&lt;/li&gt;
&lt;li&gt;Force excessive async boundary resolution&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Conceptual example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;POST /_rsc
Content-Type: application/json

{
  "type": "ServerComponent",
  "props": {
    "children": {
      "children": {
        "children": {
          ...
        }
      }
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Even if the payload is syntactically valid, React will:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Attempt to deserialize it&lt;/li&gt;
&lt;li&gt;Build an in-memory component graph&lt;/li&gt;
&lt;li&gt;Schedule execution and streaming work&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This leads to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;High CPU usage during decoding&lt;/li&gt;
&lt;li&gt;Memory pressure during graph reconstruction&lt;/li&gt;
&lt;li&gt;Worker or event-loop saturation&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Crucially, this happens without hitting user-defined code and without authentication.
&lt;/h2&gt;

&lt;h2&gt;
  
  
  This makes traditional defensive assumptions at the application layer largely ineffective.
&lt;/h2&gt;

&lt;h2&gt;
  
  
  How Source Code Exposure Can Occur
&lt;/h2&gt;

&lt;p&gt;Source code exposure is a side effect of how React handles errors during steps 4 and 5.&lt;br&gt;
When a rendering or serialization error occurs mid-stream:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;React still holds references to internal module paths&lt;/li&gt;
&lt;li&gt;Stack traces include resolved file locations&lt;/li&gt;
&lt;li&gt;Component metadata is partially serialized&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In certain edge cases, this information may:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Leak into the streamed response&lt;/li&gt;
&lt;li&gt;Appear in error payloads&lt;/li&gt;
&lt;li&gt;Be flushed before the stream is properly aborted&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example of leaked information:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Error: Failed to resolve Server Component
  at /app/src/components/admin/UserList.server.tsx
  at react-server-dom-webpack/server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This reveals:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Project directory structure&lt;/li&gt;
&lt;li&gt;Server-only component boundaries&lt;/li&gt;
&lt;li&gt;Internal module layout and naming&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  While not a standalone exploit, this materially reduces the effort required for targeted attacks.
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Why Server Actions Are Not Required
&lt;/h2&gt;

&lt;p&gt;A common misconception is that these risks only apply when using Server Actions.&lt;br&gt;
In reality:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Server Actions are an API surface&lt;/li&gt;
&lt;li&gt;RSC is a runtime and protocol&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Even a simple page like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export default async function Page() {
  return &amp;lt;Dashboard /&amp;gt;;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Still triggers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Request deserialization&lt;/li&gt;
&lt;li&gt;Component graph reconstruction&lt;/li&gt;
&lt;li&gt;Server execution and streaming&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The vulnerable logic executes regardless of whether Server Actions are defined.
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Key Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;React Server Components introduce a fundamentally new server-side execution model that combines request deserialization, component graph reconstruction, and streaming-based rendering into a single framework-managed pipeline.&lt;/li&gt;
&lt;li&gt;As a result, the effective attack surface exists before authentication, before application middleware, and before any user-defined business logic is executed.&lt;/li&gt;
&lt;li&gt;Malformed or adversarial RSC requests can lead to:&lt;/li&gt;
&lt;li&gt;Denial of Service, through excessive CPU usage, memory pressure, and worker or event-loop saturation during deserialization and component graph reconstruction&lt;/li&gt;
&lt;li&gt;Accidental disclosure of server-side implementation details, including internal file paths, component boundaries, and module layout, as a side effect of streaming error handling&lt;/li&gt;
&lt;li&gt;These issues are not caused by misconfigured applications or unsafe user code. They are framework-level vulnerabilities in the React Server Components runtime itself and cannot be mitigated reliably through application-layer defenses alone.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Official advisories and patches&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://react.dev/blog/2025/12/11/denial-of-service-and-source-code-exposure-in-react-server-components" rel="noopener noreferrer"&gt;Denial of Service and Source Code Exposure in React Server Components&lt;/a&gt;
&lt;/h3&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://nextjs.org/blog/security-update-2025-12-11" rel="noopener noreferrer"&gt;Next.js security update&lt;/a&gt;
&lt;/h3&gt;

</description>
      <category>nextjs</category>
      <category>react</category>
      <category>security</category>
      <category>servercomponent</category>
    </item>
    <item>
      <title>A Deep Dive into Nested ScrollView Behavior in React Native: Root Causes and Practical Solutions</title>
      <dc:creator>mohammad rostami</dc:creator>
      <pubDate>Mon, 24 Nov 2025 21:24:08 +0000</pubDate>
      <link>https://forem.com/mohammad_rostami_/a-deep-dive-into-nested-scrollview-behavior-in-react-native-root-causes-and-practical-solutions-bmk</link>
      <guid>https://forem.com/mohammad_rostami_/a-deep-dive-into-nested-scrollview-behavior-in-react-native-root-causes-and-practical-solutions-bmk</guid>
      <description>&lt;h2&gt;
  
  
  Hi everyone
&lt;/h2&gt;

&lt;p&gt;During the development of a recent screen in one of our applications, I faced a scenario where a section of the content needed to scroll independently, while the entire page itself was wrapped inside a parent ScrollView. At first glance, this seems like a straightforward layout. In practice, however, the behavior of nested scroll containers became unexpectedly challenging, especially when tested across platforms.&lt;/p&gt;

&lt;h2&gt;
  
  
  Observed Behavior Across Platforms
&lt;/h2&gt;

&lt;p&gt;On iOS, the internal ScrollView generally behaves as expected without requiring additional configuration.&lt;/p&gt;

&lt;p&gt;On Android, the situation is different. The inner scroll often fails to activate, gets interrupted by the outer scroll, or reacts inconsistently. This occurred not only on lower-end devices but on high-end models as well.&lt;/p&gt;

&lt;h2&gt;
  
  
  The issue becomes even more noticeable when:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The two scroll layers have different directions (for example, vertical parent and horizontal child)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The inner content has dynamic height or width&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Multiple simultaneous gestures are triggered during rapid scrolling&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It quickly became clear that this was not simply a styling conflict, but a deeper issue related to gesture priority and event handling at the platform level.&lt;/p&gt;

&lt;h2&gt;
  
  
  Root Cause Analysis: What Actually Happens Behind the Scenes
&lt;/h2&gt;

&lt;p&gt;After reviewing React Native’s gesture responder system and native scroll behavior in both iOS and Android, several key points emerged:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;On Android, the parent ScrollView receives gesture priority by default &lt;br&gt;
It attempts to determine whether the gesture belongs to itself before allowing the child ScrollView to respond. This decision is not always accurate, which often prevents the inner scroll from initiating.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;On iOS, gesture separation is more precise&lt;br&gt;
The system determines the appropriate scroll target early and allows both parent and child scroll views to operate smoothly.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Mixed-direction scrolling increases complexity&lt;br&gt;
When the parent scrolls vertically and the child scrolls horizontally, the system must re-evaluate gesture direction multiple times. On Android, this frequently results in jumps, unexpected direction changes, or the parent taking control prematurely.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Dynamic layout measurement affects gesture routing&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Incorrect or late size calculations can cause the inner ScrollView to lose gesture ownership too early.&lt;/p&gt;

&lt;h2&gt;
  
  
  Practical Solutions Based on Testing
&lt;/h2&gt;

&lt;p&gt;Several solutions helped achieve consistent, reliable behavior for nested scrolling:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Enable nestedScrollEnabled on the inner ScrollView (Android)
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;ScrollView&amp;gt;

     &amp;lt;ScrollView nestedScrollEnabled&amp;gt;

        {/* content */}

     &amp;lt;/ScrollView&amp;gt;

&amp;lt;/ScrollView&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the foundational setting required to ensure the child scroll can properly receive gestures.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use flexGrow for proper content measurement
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;contentContainerStyle={{ flexGrow: 1 }}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This ensures the inner ScrollView’s content is measured correctly, reducing gesture conflicts with the parent view.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Handle mixed-direction scrolling intentionally&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When the parent and child scroll in different directions, it is often beneficial to temporarily enable or disable one of the scroll containers based on the detected gesture direction.&lt;/p&gt;

&lt;p&gt;This approach helps the system correctly determine which layer should receive the gesture and prevents unintended handoffs during scroll.&lt;/p&gt;

&lt;h2&gt;
  
  
  Complete Example
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// https://www.linkedin.com/in/mohammadrostami/
import React from 'react';
import { ScrollView, View, Text, StyleSheet } from 'react-native';

export default function NestedScrollExample() {
  return (
    &amp;lt;ScrollView style={styles.parentScroll}&amp;gt;
      &amp;lt;View style={styles.container}&amp;gt;

        &amp;lt;Text style={styles.title}&amp;gt;Parent ScrollView&amp;lt;/Text&amp;gt;

        &amp;lt;ScrollView
          nestedScrollEnabled
          style={styles.childScroll}
          contentContainerStyle={{ flexGrow: 1 }}
        &amp;gt;
          &amp;lt;View style={styles.childContent}&amp;gt;
            {Array.from({ length: 25 }).map((_, i) =&amp;gt; (
              &amp;lt;Text style={styles.item} key={i}&amp;gt;
                Child Item {i + 1}
              &amp;lt;/Text&amp;gt;
            ))}
          &amp;lt;/View&amp;gt;
        &amp;lt;/ScrollView&amp;gt;

        &amp;lt;View style={styles.footer}&amp;gt;
          &amp;lt;Text style={styles.footerText}&amp;gt;Footer Content&amp;lt;/Text&amp;gt;
        &amp;lt;/View&amp;gt;

      &amp;lt;/View&amp;gt;
    &amp;lt;/ScrollView&amp;gt;
  );
}

const styles = StyleSheet.create({
  parentScroll: {
    flex: 1,
    backgroundColor: '#fafafa',
  },
  container: {
    padding: 16,
  },
  title: {
    fontSize: 18,
    marginBottom: 12,
  },
  childScroll: {
    height: 250,
    borderRadius: 8,
    borderWidth: 1,
    borderColor: '#ccc',
  },
  childContent: {
    padding: 12,
  },
  item: {
    paddingVertical: 10,
    fontSize: 16,
  },
  footer: {
    marginTop: 30,
    padding: 12,
    backgroundColor: '#eee',
    borderRadius: 8,
  },
  footerText: {
    fontSize: 16,
  },
});

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

&lt;/div&gt;



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

&lt;p&gt;Nested ScrollViews introduce a set of platform-specific challenges in React Native, particularly in Android where gesture routing differs significantly from iOS. Understanding how gestures are prioritized, how mixed-direction scrolling is handled, and how layout measurement affects scroll behavior is essential for creating smooth, predictable user experiences.&lt;br&gt;
Properly configuring nestedScrollEnabled, managing dynamic content sizing, and intentionally controlling scroll interactions are key to resolving these issues in production-grade applications.&lt;/p&gt;

</description>
      <category>android</category>
      <category>ui</category>
      <category>ios</category>
      <category>reactnative</category>
    </item>
  </channel>
</rss>
