<?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>DEV Community: Rajath</title>
    <description>The latest articles on DEV Community by Rajath (@rajath_shiremath_523cd54).</description>
    <link>https://dev.to/rajath_shiremath_523cd54</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%2F3796134%2F75423fb5-2ce8-4277-ab7d-89e938a629eb.png</url>
      <title>DEV Community: Rajath</title>
      <link>https://dev.to/rajath_shiremath_523cd54</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rajath_shiremath_523cd54"/>
    <language>en</language>
    <item>
      <title>If You're Building Microservices Without This, You're Doing It Wrong</title>
      <dc:creator>Rajath</dc:creator>
      <pubDate>Fri, 06 Mar 2026 19:18:30 +0000</pubDate>
      <link>https://dev.to/rajath_shiremath_523cd54/if-youre-building-microservices-without-this-youre-doing-it-wrong-f53</link>
      <guid>https://dev.to/rajath_shiremath_523cd54/if-youre-building-microservices-without-this-youre-doing-it-wrong-f53</guid>
      <description>&lt;p&gt;Imagine walking into a massive, bustling restaurant. What if, instead of speaking to a waiter, you had to walk into the kitchen yourself? You’d have to track down the grill chef for your steak, find the pastry chef for your dessert, and flag down the bartender for your drink.&lt;/p&gt;

&lt;p&gt;It would be exhausting, chaotic, and horribly inefficient.&lt;/p&gt;

&lt;p&gt;In the software world, client applications (like the mobile apps on your phone or the web browsers on your laptop) used to face this exact problem when trying to talk to modern cloud applications. That is, until the API Gateway came along to act as the ultimate waiter, concierge, and traffic cop all rolled into one.&lt;/p&gt;

&lt;p&gt;If you’re wrapping your head around modern system architecture, understanding the &lt;strong&gt;API Gateway&lt;/strong&gt; is a massive lightbulb moment. Let’s break down what it is, why it exists, and how it keeps the digital world from collapsing into chaos.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What Exactly is an API Gateway?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;At its most basic level, an API Gateway is a piece of software that sits between a client and a collection of backend services.&lt;/p&gt;

&lt;p&gt;Instead of an app trying to talk to a dozen different servers to load a single webpage, the app talks to only the API Gateway. The gateway takes that request, figures out which backend services are needed to fulfill it, gathers all the data, and hands a neat, completed package back to the user.&lt;br&gt;
It acts as the single "front door" for your application. Whether a request is coming from an iPhone, an Android, or a web browser, they all knock on the same door.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Do We Need It? (The "Before and After")&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To understand why API Gateways are suddenly everywhere, we have to look at how software design has changed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Old Way: Monoliths&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Historically, applications were built as monoliths—everything (billing, user profiles, inventory, etc.) lived in one giant codebase on one server.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The New Way: Microservices&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Today, we use microservices. We break applications down into dozens or even hundreds of tiny, independent services. This is great for developers because it makes updating and scaling much easier. But it’s a nightmare for the client side.&lt;/p&gt;

&lt;p&gt;Without an API Gateway, a mobile app loading an e-commerce storefront would have to make separate network calls over the internet to the Inventory Service, the Pricing Service, the Reviews Service, and the Recommendation Service.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Here’s a comparison of how the communication flow changes.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Direct Client-to-Microservice Communication (No Gateway)&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%2Fwo0vt91wr6r3y1mpou6i.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%2Fwo0vt91wr6r3y1mpou6i.png" alt=" " width="800" height="210"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This approach is slow, consumes user battery, and makes the app fragile.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Communication with an API Gateway&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%2Fe6tchxbnqz9gvkugjksa.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%2Fe6tchxbnqz9gvkugjksa.png" alt=" " width="800" height="329"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By using an API Gateway, the complexity is hidden from the user. The mobile app makes one call to the gateway. The gateway does the heavy lifting of running around the "kitchen" to fetch the inventory, pricing, and reviews, over the ultra-fast internal network, saving the user's battery life and sanity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The 4 Superpowers of an API Gateway&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Routing traffic is just the beginning. Because the gateway is the only way in or out of your backend, it’s the perfect place to enforce rules. We can visualize these 'Superpowers' as layers of responsibility.&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%2Fv2tsefink4t5c6imzpqo.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%2Fv2tsefink4t5c6imzpqo.png" alt=" " width="800" height="193"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let's break these down:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The Bouncer (Security &amp;amp; Authentication):&lt;/strong&gt; Instead of forcing every single microservice to independently verify if a user is logged in, the gateway handles it. It checks the user's API keys, JWT tokens, or OAuth credentials right at the door. If you aren't on the list, you don't get in.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The Shield (Rate Limiting &amp;amp; Throttling):&lt;/strong&gt; If a malicious bot network tries to flood your servers, or a viral post sends a million users your way at once, the API Gateway steps in. It limits how many requests a single user or IP address can make per second, preventing your backend servers from crashing.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The Translator (Protocol Translation):&lt;/strong&gt; Sometimes, the front-end speaks a different language than the back-end. A web browser might request data using standard HTTP, but your internal microservices might communicate using faster, more complex protocols like gRPC or WebSockets. The gateway translates these requests on the fly.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The Speedster (Caching):&lt;/strong&gt; If thousands of people are asking for the exact same data (like the homepage of a news site), the gateway can save a copy of the response. Instead of bothering the backend databases every single time, it just hands the user the cached copy, drastically speeding up load times.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Should You Always Use One?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;While they sound amazing, API gateways aren't a silver bullet. They introduce a single point of failure and slightly increase latency for simple setups.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Here is a quick decision flow to see if you need one:&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%2Fvcm770nt90lls0p8gnsu.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%2Fvcm770nt90lls0p8gnsu.png" alt=" " width="716" height="1069"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;🚀 Keep Learning!&lt;/p&gt;

&lt;p&gt;If you enjoyed this breakdown of API Gateways and want to dive deeper into software architecture, I've got you covered.&lt;/p&gt;




&lt;h3&gt;
  
  
  🌍 Read this anywhere!
&lt;/h3&gt;

&lt;p&gt;Prefer reading on DEV Community? You can also find this article (and drop a unicorn reaction!) over on my dev.to profile:&lt;br&gt;
🦄 &lt;strong&gt;&lt;a href="https://dev.to/rajath_shiremath_523cd54/stop-accepting-malware-the-pragmatic-guide-to-secure-file-uploads-58go"&gt;Read on dev.to&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Curious about how to actually set one of these up? Stay tuned for my next blog post where we'll dive into the implementation details!&lt;/p&gt;

</description>
      <category>api</category>
      <category>apigateway</category>
      <category>softwaredevelopment</category>
      <category>microservices</category>
    </item>
    <item>
      <title>How to Protect Your Web App from Malware via File Uploads</title>
      <dc:creator>Rajath</dc:creator>
      <pubDate>Fri, 27 Feb 2026 08:46:06 +0000</pubDate>
      <link>https://dev.to/rajath_shiremath_523cd54/stop-accepting-malware-the-pragmatic-guide-to-secure-file-uploads-58go</link>
      <guid>https://dev.to/rajath_shiremath_523cd54/stop-accepting-malware-the-pragmatic-guide-to-secure-file-uploads-58go</guid>
      <description>&lt;p&gt;If your web application has an &lt;code&gt;&amp;lt;input type="file"&amp;gt;&lt;/code&gt; tag anywhere in its architecture, you have a massive target on your back.&lt;/p&gt;

&lt;p&gt;File upload features are essential for modern applications—whether it’s uploading a profile picture, a CSV of user data, or a PDF report. However, if improperly handled, a simple file upload form is the easiest way for an attacker to achieve Remote Code Execution (RCE), deface your server, or distribute malware to your users.&lt;/p&gt;

&lt;p&gt;In this post, we are going to look at the real-world vulnerabilities associated with file uploads and build a "defense in depth" strategy to secure them.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Threat Landscape: What Can Go Wrong?
&lt;/h2&gt;

&lt;p&gt;When you allow a user to upload a file, you are inherently allowing them to write data to your disk. If you blindly trust the file they provide, you open yourself up to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Web Shells (RCE):&lt;/strong&gt; An attacker uploads a &lt;code&gt;.php&lt;/code&gt; or &lt;code&gt;.jsp&lt;/code&gt; file containing a malicious script. If your server executes it, they own your machine.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Directory Traversal:&lt;/strong&gt; An attacker intercepts the upload request and changes the filename to &lt;code&gt;../../../etc/passwd&lt;/code&gt; to overwrite critical system files.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Denial of Service (DoS):&lt;/strong&gt; An attacker uploads a massive 10GB file, or a "zip bomb," instantly consuming all your server's memory and disk space.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Cross-Site Scripting (XSS):&lt;/strong&gt; An attacker uploads a malicious &lt;code&gt;.svg&lt;/code&gt; or &lt;code&gt;.html&lt;/code&gt; file masquerading as an image. When another user views it, malicious JavaScript executes in their browser.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To stop these, we need a multi-layered approach.&lt;/p&gt;

&lt;h2&gt;
  
  
  Layer 1: Never Trust User Input (Validation)
&lt;/h2&gt;

&lt;p&gt;The biggest mistake developers make is trusting the file extension or the &lt;code&gt;Content-Type&lt;/code&gt; header sent by the client. Both are trivially easy to spoof using tools like Burp Suite or Postman.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bad Practice:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Python&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# DO NOT DO THIS
if filename.endswith('.jpg') and request.headers['Content-Type'] == 'image/jpeg':
    save_file() 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Good Practice: Validate Magic Bytes&lt;/strong&gt; Instead of trusting the extension, you must inspect the actual contents of the file. Every file type has a "Magic Number" or file signature—a short sequence of bytes at the very beginning of the file that identifies its true format.&lt;/p&gt;

&lt;p&gt;Here is how you validate magic bytes in Python using the &lt;code&gt;python-magic&lt;/code&gt; library:&lt;/p&gt;

&lt;p&gt;Python&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import magic
from werkzeug.utils import secure_filename

ALLOWED_MIME_TYPES = {'image/jpeg', 'image/png', 'application/pdf'}

def is_safe_file(file_stream):
    # Read the first 2048 bytes to determine the file signature
    file_header = file_stream.read(2048)
    file_stream.seek(0) # Reset the pointer back to the start!

    # Identify the true MIME type based on the file contents
    actual_mime_type = magic.from_buffer(file_header, mime=True)

    return actual_mime_type in ALLOWED_MIME_TYPES
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Layer 2: Filename Sanitization
&lt;/h2&gt;

&lt;p&gt;Never use the original filename provided by the user. Attackers use crafted filenames to execute Path Traversal attacks, attempting to save files outside of your designated upload directory.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Solution:&lt;/strong&gt; Completely discard the user's filename. Generate a unique, random string (like a UUID) for the file upon upload, and append the validated extension to it. If you need to keep the original filename for UI purposes, store it safely as a string in your SQL database, not on the filesystem.&lt;/p&gt;

&lt;p&gt;Python&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import uuid
import os

def generate_safe_filename(actual_extension):
    # Generates a name like: 550e8400-e29b-41d4-a716-446655440000.jpg
    random_name = str(uuid.uuid4())
    return f"{random_name}.{actual_extension}"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Layer 3: Secure Storage Architecture
&lt;/h2&gt;

&lt;p&gt;If you take only one lesson from this article, let it be this: &lt;strong&gt;Never store uploaded files in your web root.&lt;/strong&gt; If your web server (like Apache or Nginx) is configured to serve files from &lt;code&gt;/var/www/html&lt;/code&gt;, and you save user uploads to &lt;code&gt;/var/www/html/uploads&lt;/code&gt;, you are risking execution. If an attacker slips a script past your filters, they can simply navigate to &lt;code&gt;yourdomain.com/uploads/shell.php&lt;/code&gt; to execute it.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Modern Standard: Cloud Object Storage (S3)
&lt;/h3&gt;

&lt;p&gt;The safest architectural pattern is to decouple file storage from your application server entirely.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Direct-to-S3 via Presigned URLs:&lt;/strong&gt; Instead of routing a massive file through your Java or Python backend (which ties up server threads and costs money), your backend should generate a temporary, restricted "Presigned POST URL".&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The client's browser uses this URL to upload the file directly to an AWS S3 bucket.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The S3 bucket is configured with policies that prevent execution, and you can trigger AWS Lambda functions to automatically scan the uploaded file with an antivirus (like ClamAV) before moving it to a "Clean" bucket.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&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%2Fhtq49stbphgsn2b98gmb.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%2Fhtq49stbphgsn2b98gmb.png" alt=" " width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How Big Tech Handles Uploads at Scale
&lt;/h2&gt;

&lt;p&gt;When companies like &lt;strong&gt;Slack&lt;/strong&gt;, &lt;strong&gt;Netflix&lt;/strong&gt;, or &lt;strong&gt;Meta&lt;/strong&gt; process millions of files an hour, passing large blobs of data through a standard web server is a recipe for crashing your infrastructure. They take the "Defense in Depth" strategy even further using a few core patterns:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. The Quarantine Pattern (Asynchronous Scanning)&lt;/strong&gt; Large applications never upload files directly to a production environment. Instead, they use a "Quarantine Bucket." When a user uploads a file directly to cloud storage, it triggers an event-driven serverless function (like AWS Lambda). This function asynchronously runs an antivirus scanner (like ClamAV) and checks the magic bytes. Only if the file gets a clean bill of health is it moved to the primary production bucket.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Resumable Uploads (The Tus Protocol)&lt;/strong&gt; If a user is uploading a massive 4K video or a huge dataset and their connection drops at 99%, failing the upload is terrible UX. Companies like &lt;strong&gt;Vimeo&lt;/strong&gt; and &lt;strong&gt;Cloudflare&lt;/strong&gt; use the open-source &lt;strong&gt;Tus protocol&lt;/strong&gt; or AWS Multipart Uploads. This breaks the file down into small chunks and uploads them individually, allowing the client to pause and resume uploads seamlessly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Edge Processing (CDNs)&lt;/strong&gt; Once a file is validated and stored securely, it needs to be served fast. Instead of storing five different sizes of the same profile picture, large platforms use Edge networks (like Cloudflare, AWS CloudFront, or Akamai). They store the high-resolution original securely, and then dynamically compress and resize the image "on the fly" at the edge node closest to the user requesting it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary Checklist for Secure Uploads
&lt;/h2&gt;

&lt;p&gt;Before you deploy your next file upload feature, ensure you check these boxes:&lt;/p&gt;

&lt;p&gt;✅ &lt;strong&gt;Implement a strict Allow list&lt;/strong&gt; for file types (no blacklisting).&lt;/p&gt;

&lt;p&gt;✅ &lt;strong&gt;Validate file types using Magic Bytes&lt;/strong&gt;, not extensions.&lt;/p&gt;

&lt;p&gt;✅ &lt;strong&gt;Enforce Max File Size limits&lt;/strong&gt; at the server configuration level to prevent DoS.&lt;/p&gt;

&lt;p&gt;✅ &lt;strong&gt;Rename all files&lt;/strong&gt; using UUIDs.&lt;/p&gt;

&lt;p&gt;✅ &lt;strong&gt;Store files outside the web root&lt;/strong&gt; or, ideally, in isolated Cloud Object Storage like S3.&lt;/p&gt;

&lt;p&gt;✅ &lt;strong&gt;Serve files with the correct headers:&lt;/strong&gt; &lt;code&gt;X-Content-Type-Options: nosniff&lt;/code&gt; and &lt;code&gt;Content-Disposition: attachment&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Handling file uploads securely takes a bit more architecture, but it is the difference between a robust enterprise application and a compromised server.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Have you encountered any tricky edge cases when handling file uploads in your own projects? Let me know in the comments below!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>cybersecurity</category>
      <category>security</category>
      <category>tutorial</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
