Urgent.News

What's breaking now, across thousands of outlets.

Tech

5 Security Mistakes I See in Flask + React Apps (and How to Fix Them)

Flask and React are a great pairing: fast to build, flexible, and easy to deploy. But that same speed means security often gets pushed to "later," and later usually means after something breaks. I work as a secure software engineer, and these five mistakes keep showing up in tutorials, side projects, and early-stage apps. None of them are exotic. All of them are fixable in a few lines. 1.…

Flask and React are a popular combination for building web applications, offering speed, flexibility, and ease of deployment. However, the rapid development process can lead to overlooking security measures, which can have serious consequences if exploited. As a secure software engineer, I have observed five common mistakes that frequently appear in Flask+React applications. These issues are not complex and can be easily addressed with a few lines of code.

1. Ignoring user input validation: The error occurs when developers directly read values from the `request.get_json()` method and treat them as safe and properly formatted. This approach can result in `KeyError` exceptions if fields are missing or in cases where unexpected data types or oversized strings are passed to other parts of the application.

To prevent this, it is crucial to validate every request body against a defined schema before processing it. Pydantic is a recommended library for schema validation (install it using `pip install pydantic email-validator`).

2. Storing JSON Web Tokens (JWTs) in localStorage: Saving the access token in `localStorage` exposes it to potential attacks, as any JavaScript running on the page can read this data. An XSS vulnerability, which can be introduced by an unsanitized dependency or a maliciously crafted piece of HTML, could allow an attacker to steal the session.

To mitigate this risk, store the JWT in an `HttpOnly`, `Secure`, `SameSite` cookie. This ensures that JavaScript cannot access the token. With the Flask extension `flask-jwt-extended`, you can configure the application to use cookies for token storage:

```python

# ✅ After (Flask)

from flask import jsonify

from flask_jwt_extended import (JWTManager, create_access_token, set_access_cookies)

app.config['JWT_TOKEN_LOCATION'] = ['cookies']

app.config['JWT_COOKIE_SECURE'] = True # HTTPS only

app.config['JWT_COOKIE_SAMESITE'] = 'Lax'

app.config['JWT_COOKIE_CSRF_PROTECT'] = True # keep this on with cookies

jwt = JWTManager(app)

@app.route('/login', methods=['POST'])

def login():

# ...verify credentials...

token = create_access_token(identity=str(user.id))

resp = jsonify({'message': 'logged in'})

set_access_cookies(resp, token)

return resp

```

On the React frontend, ensure that every request includes the token in the `Authorization` header using a cookie, rather than storing it in `localStorage`.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

What happens when an offline POS sale syncs twice?

A cashier completes a sale while the connection is down. Later, the server saves it, but the response never reaches the device. The app retries.

  • Unique client sale ID assigned to prevent duplicate transactions.
  • Server handles retries safely with unique database constraint.
  • Testing essential to verify receipt number and inventory accuracy.

NestJS vs Express.js: Choosing the Right Framework for Your Next Node.js Project

Node.js is used by 48.7% of developers in the Stack Overflow Developer Survey 2025. Inside that group, Express.js is used by 19.9% of respondents and NestJS by 6.7%.

  • 48.7% of developers used Node.js in 2025 Stack Overflow survey
  • NestJS has 6.7% adoption, growing due to structured approach
  • Express.js excels in speed and control, while NestJS offers structure and features

How do you tune speculative decoding in a production serving stack?

Tune speculative decoding against your own traffic, not a benchmark. Choose a method that fits your workload, set draft length from measured acceptance rate, and re-test at production concurrency…

  • Base speculative decoding method on your own traffic data, not benchmarks.
  • Choose n-gram or suffix decoding for modest speedup; use EAGLE or MTP for best latency reduction.
  • Adjust draft length based on acceptance rate; test multiple values and monitor per-request metrics.

Running untrusted pull request code from agents and contributors

Originally published on sandscale.dev . A pull request is a request to run someone else's code on your machine. CI has always worked this way: check out the branch, install dependencies, run the…

  • Pull requests run untrusted code, posing risks like code escaping or data exfiltration
  • Sandscale's sandbox creates a separate kernel and network environment for each PR
  • After tests, sandbox should be stopped and discarded to prevent lingering malicious code

More from Friday 20 November →