<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Mahim Safa Blog]]></title><description><![CDATA[Mahim Safa Blog]]></description><link>https://blog.mahimsafa.com</link><image><url>https://cdn.hashnode.com/res/hashnode/image/upload/v1674909101946/gFkHzatCq.png</url><title>Mahim Safa Blog</title><link>https://blog.mahimsafa.com</link></image><generator>RSS for Node</generator><lastBuildDate>Thu, 21 May 2026 00:33:47 GMT</lastBuildDate><atom:link href="https://blog.mahimsafa.com/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Built and Deployed a Scalable MERN Stack E-commerce Application on AWS]]></title><description><![CDATA[Project Goal
This is a very high-level overview of building and deploying a MERN stack e-commerce application on AWS with scalability. I just finished the project recently on Fiverr.
Overview:
As a freelance developer, I was tasked with building and ...]]></description><link>https://blog.mahimsafa.com/built-and-deployed-a-scalable-mern-stack-e-commerce-application-on-aws</link><guid isPermaLink="true">https://blog.mahimsafa.com/built-and-deployed-a-scalable-mern-stack-e-commerce-application-on-aws</guid><category><![CDATA[React]]></category><category><![CDATA[Node.js]]></category><category><![CDATA[AWS]]></category><category><![CDATA[APIs]]></category><category><![CDATA[serverless]]></category><dc:creator><![CDATA[Mahim Safa]]></dc:creator><pubDate>Thu, 02 Mar 2023 06:00:39 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1677696651592/2d6a4f83-5a15-4d32-bef8-1556cd432a58.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-project-goal">Project Goal</h2>
<p>This is a very high-level overview of building and deploying a MERN stack e-commerce application on AWS with scalability. I just finished the project recently on Fiverr.</p>
<h3 id="heading-overview">Overview:</h3>
<p>As a freelance developer, I was tasked with building and deploying a scalable MERN stack e-commerce application on AWS. The goal was to create an e-commerce application that could handle a high volume of traffic while being reliable, secure, and scalable. To achieve this, I used several AWS services such as Amazon DocumentDB, AWS Amplify, AWS Lambda, Amazon API Gateway, AWS S3, and CloudFront.</p>
<h3 id="heading-challenges">Challenges:</h3>
<p>The project presented a few challenges, such as ensuring the security and reliability of the application, integrating a payment gateway for processing transactions, coordinating with other developers working on the project, and efficiently deploying the application on AWS.</p>
<h3 id="heading-solutions">Solutions:</h3>
<p>To address the security and reliability concerns of the application, I utilized Amazon DocumentDB as the backend database. This allowed me to leverage the scalability and reliability of AWS's database services, ensuring that the application could handle high volumes of traffic without compromising performance. Additionally, I implemented security measures such as encryption of data at rest and in transit.</p>
<p>For the frontend development, I used AWS Amplify to develop and deploy the React application. AWS Amplify provides a comprehensive suite of tools for building and deploying scalable and reliable applications, including authentication, data storage, and API integration. I also integrated a payment gateway to process transactions securely.</p>
<p>For the backend architecture, I used AWS Lambda and Amazon API Gateway. This allowed me to create a flexible and robust backend that could manage the API endpoints efficiently, ensuring that the backend was responsive and could handle high volumes of traffic. To prevent security breaches, I implemented measures such as rate limiting and input validation.</p>
<p>To store user-generated content, such as product images and descriptions, I used AWS S3 as the storage service. This allowed me to store and retrieve data quickly and reliably, ensuring that the application could handle large amounts of data without compromising performance.</p>
<p>Finally, to optimize the application's performance, I used CloudFront as the CDN. CloudFront helped me to improve the application's performance by caching content closer to the users, reducing the latency, and improving the application's responsiveness.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1677696314320/b585f4df-fe5f-49d0-b643-320fb51efa0b.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-results">Results:</h3>
<p>The project was a success, and the e-commerce application was deployed on AWS with high reliability and scalability. Using AWS services such as Amazon DocumentDB, AWS Amplify, AWS Lambda, Amazon API Gateway, AWS S3, and CloudFront allowed me to build a flexible and robust e-commerce application that could handle high volumes of traffic without compromising performance. The collaboration with other developers working on the project was seamless, and the application was delivered on time and within budget. The integration of the payment gateway enabled secure transactions for customers, increasing trust and improving the user experience.</p>
<h3 id="heading-conclusion">Conclusion:</h3>
<p>Building and deploying a scalable MERN stack e-commerce application on AWS requires expertise and knowledge of AWS services. By utilizing AWS Amplify, Amazon DocumentDB, AWS Lambda, Amazon API Gateway, AWS S3, and CloudFront, I was able to create a reliable, scalable, and performant e-commerce application that met the client's requirements. My expertise in AWS services and MERN stack development enabled me to contribute to the success of the project.</p>
]]></content:encoded></item><item><title><![CDATA[MongoDB: Avoid using unbounded arrays in documents]]></title><description><![CDATA[Hi everyone. Hope you are doing well. Today I will show you a scenario with the pros and cons that why you shouldn’t use unbound arrays in a MongoDB document. So without further ado let’s get started.
First, understand the scenario. Let’s assume we h...]]></description><link>https://blog.mahimsafa.com/mongodb-avoid-using-unbounded-arrays-in-documents-fcfa12e84dc4</link><guid isPermaLink="true">https://blog.mahimsafa.com/mongodb-avoid-using-unbounded-arrays-in-documents-fcfa12e84dc4</guid><category><![CDATA[development]]></category><category><![CDATA[MongoDB]]></category><category><![CDATA[optimization]]></category><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[Mahim Safa]]></dc:creator><pubDate>Wed, 22 Jun 2022 08:45:56 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1674910150953/fd7a8ea6-b81d-4c0d-a8e2-ea67bcd335a8.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Hi everyone. Hope you are doing well. Today I will show you a scenario with the pros and cons that why you shouldn’t use unbound arrays in a MongoDB document. So without further ado let’s get started.</p>
<p>First, understand the scenario. Let’s assume we have a social media application where a user can follow multiple users and vice versa. So the initial MongoDB schema should look like this.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1674910133667/6eb2d597-f89c-4305-abe9-50327bd8cc0a.png" alt /></p>
<p>Initial schema</p>
<p>Here we should pay attention to 2 fields <strong><em>followers</em></strong> and <strong><em>followings.</em></strong> At the start of our application, we won’t have too much traffic as well as users. Let’s say we started with 10-20 k users. So at this scale, if a user follows another user it will store all data in that array of the schema. So documents stored in followers or followings array will have an average of 3 digits. In the worst-case scenario, it can go up to 4 digits. MongoDB can handle this much data for the time being. But the operation Can still be slow a little bit. This can be optimized. In this case, you can query for the <strong><em>followers</em></strong> in the following way.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1674910136092/9375a90d-61c9-4046-bc60-1f90f7332aec.png" alt /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1674910139097/991cd977-bd61-44b4-a763-165202c00ca9.png" alt="Aggregation Framework" /></p>
<p>Get all followers for a user</p>
<p><strong>But</strong> when the application grows in the number of users it can be hundreds of thousands of users even it can be millions of users. Then this initial user schema won’t work as expected on the other hand a single document in MongoDB can be max 16 MB. if a user can manage to get hundreds of thousands of followers the database will fail.</p>
<p><strong>So</strong> to overcome this problem we can split the schema into two schemas. One is <strong><em>the User</em></strong> schema and another is <strong><em>Follow</em></strong> schema. These schemas should look like this.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1674910140784/5b48c0c0-5cdd-44ed-abb0-570200de6199.png" alt /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1674910143361/d37295dd-ce98-4911-8b3b-964adfc7710d.png" alt /></p>
<p>Optimized schema</p>
<p>Now, this schema is more optimized and scalable than the previous one. In this model, a user can follow or can have millions of followers without any issue which was previously impossible. Now in this case you can’t use the previously used query to fetch all followers of a user. Now to get all <strong><em>followers</em></strong> of a user you need a query something like this.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1674910146323/78c3704f-591b-44d5-ac11-70012896a39f.png" alt="Mongoose" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1674910148650/9ea02021-8b57-440b-a31a-248dcfcc0af9.png" alt="Aggregation Framework" /></p>
<p>Don’t be confused about why I am filtering with <em>the following</em> field to get followers. just take a closer look on <strong><em>follow schema</em></strong> and give it a think you will understand easily.</p>
<p>That is all for today. Hope you find it useful. If you do please give it a clap and share it with your friends. If you like this kind of write-up consider following me. If you have any doubts you can always reach out to me.</p>
<p>Thank you for sticking this much.</p>
]]></content:encoded></item><item><title><![CDATA[How I Hacked Dhaka University affiliated 7C.]]></title><description><![CDATA[Assalamu alaykum,I am Mahim Safa, a student at Dhaka College. There are 7 colleges part of Dhaka University. Those are:

Dhaka College

Eden Mohila College

Begum Badrunnesa Gov. College

Government Titumir College

Government Bangla College

Kabi Na...]]></description><link>https://blog.mahimsafa.com/how-i-hacked-dhaka-university-affiliated-7c-213f158abbaf</link><guid isPermaLink="true">https://blog.mahimsafa.com/how-i-hacked-dhaka-university-affiliated-7c-213f158abbaf</guid><category><![CDATA[hacking]]></category><category><![CDATA[SQL]]></category><category><![CDATA[PHP]]></category><dc:creator><![CDATA[Mahim Safa]]></dc:creator><pubDate>Wed, 26 May 2021 14:46:01 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1674910162867/a73e994b-01a8-4337-a8a2-5bcbe6b3c9ff.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Assalamu alaykum,<br />I am Mahim Safa, a student at Dhaka College. There are 7 colleges part of Dhaka University. Those are:</p>
<ul>
<li><p>Dhaka College</p>
</li>
<li><p>Eden Mohila College</p>
</li>
<li><p>Begum Badrunnesa Gov. College</p>
</li>
<li><p>Government Titumir College</p>
</li>
<li><p>Government Bangla College</p>
</li>
<li><p>Kabi Nazrul Government College</p>
</li>
<li><p>Govt. Shaheed Suhrawardy College, Dhaka</p>
</li>
</ul>
<p>These are the 7 colleges under Dhaka University. There are about 243,000+ students are studying here currently. All of their official operations are operated by an online web portal. One of the main operations is “Yearly Form Fill Up”. During this period a huge amount of money transaction is done here. So only in this form fill up period an attacker can do huge damage of approx <strong>729,000,000 TAKA</strong>, in dollars which is about <strong>8,604,693 USD</strong>. Also, there was a <strong>reflected XSS</strong> vulnerability but that can not be marked as critical. Now let’s see how I exploited the service.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1674910156045/9b9cda53-37b3-443b-9e0a-215514e39d3d.png" alt /></p>
<p>So according to our college notice, I was given a link to the web portal for form fill up. I logged into the portal with my id given by my college. While submitting the form the URL caught my eye. So I was a little bit curious about the endpoint. So I started trying playing with the URL. At a point, I found <strong>SQLi</strong> in that particular endpoint.</p>
<blockquote>
<p><code>https://web-portal-domain.com/students/form_preview.php?s_year_code=1&amp;session_id=20&amp;exam_id=17</code></p>
<p><code>https://web-portal-domain.com/students/form_preview.php?s_year_code=1&amp;session_id=20&amp;exam_id=-17' union select 1,2,3,group_concat(username,0x3a,password),5,6 from admin — -</code></p>
</blockquote>
<p>So I tried playing around with SQLi. Then I was able to extract data from the database. I found the Server Admin panel credentials, college admin panel credentials, and login credentials for all 243000+ students and their personal info like Full Name, Contact Number, Address, Fathers's Name, Mothers's Name, and many more. From the college admin panel, I was able to bypass any student transaction. On the other hand from the server admin panel, I was able to add, modify, remove any student. Let’s move on...</p>
<p>After accessing the database I was curious about if I could get access to the server. So I tried some SQL functions if it could get me access to RCE on the server. First I tried to <em>read arbitrary files</em> using the <em>load_file()</em> function.</p>
<blockquote>
<p><code>https://web-portal-domain.com/students/form_preview.php?s_year_code=1&amp;session_id=20&amp;exam_id=-17' union select 1,2,3,load_file(‘/etc/passwd’),5,6 — -</code></p>
</blockquote>
<p>The SQL query was executed successfully. It allowed me to read all the files which were permitted by the webserver. Through this <strong><em>Arbitrary File Read,</em></strong> I was able to read all the source codes of the website. Then I tried to find out a way of writing files to the server to get RCE. So I tried <strong><em>INTO OUTFILE</em></strong> method to write files.</p>
<blockquote>
<p><code>https://web-portal-domain.com/students/form_preview.php?s_year_code=1&amp;session_id=20&amp;exam_id=-17' union select 1,2,3,“”,5,6 INTO OUTFILE ‘/var/www/html/images/shell.php’ — -</code></p>
</blockquote>
<p>But unfortunately, it was not permitted to write on that webserver directory. That’s why I was unable to get an RCE on the server.</p>
<p>But in the end, it was a huge vulnerability and could drive into a huge data loss. After reporting the threat they resolved it.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1674910158229/9827255c-f820-47b3-b5a0-d14861dd6bfd.png" alt /></p>
<p>That's all for now. Thanks for your time.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1674910160473/bcb5bd11-4a60-440c-9639-4a16b1d7236b.jpeg" alt="https://i.imgur.com/jRZ2iVS.jpeg" /></p>
]]></content:encoded></item></channel></rss>