Articles

Articles

Practical writing on building digital products, cybersecurity, and AI in a developer's daily work.

More topics (2)
  • 3 min read#App security#Web development

    Your page listens for postMessage? Any site can send it a message

    Any window can send postMessage to your page. Check event.origin before you trust a message, check its shape, and set targetOrigin instead of * when you send.

  • 3 min read#Developer tools#Web development

    Need to force push after a rebase? Use --force-with-lease

    git push --force-with-lease overwrites the remote branch only if it is still at the value you expect, so you do not wipe a teammate's commits. Add --force-if-includes when something fetches in the background.

  • 3 min read#Web development#Developer tools

    Several workers grabbing the same job? Use SKIP LOCKED in PostgreSQL

    With FOR UPDATE SKIP LOCKED, each worker takes a row nobody has locked and skips locked rows instead of waiting. That turns a plain PostgreSQL table into a job queue.

  • 4 min read#App security#Web development

    Left the .git folder on your server? Anyone can download your code

    If the .git folder went out with your deploy and opens in a browser, it holds every version of your code. Check the HEAD link now, and block the folder in your server config.

  • 3 min read#App security#Web development

    Why your password reset link can point to an attacker's domain

    Your app builds the link from the Host header that the request itself sends. Limit the domains you accept, and build email links from a fixed address in your settings.

  • 3 min read#Web development#Developer tools

    Two edits at once and one is lost? ETag and If-Match stop it

    The ETag header gives each version of a resource a tag. With If-None-Match the server answers 304 with no body, and with If-Match it refuses a save with 412 if someone edited first.

  • 3 min read#Web development#Developer tools

    Installing a package just to read .env? Use node --env-file

    Node.js reads your variables file itself with the --env-file flag, no package needed. But a value already in the environment wins over the file, and a missing file stops the start.

  • 3 min read#App security#Web development

    Anyone can send email as your domain: close it with DMARC

    A DMARC record is a TXT line at _dmarc on your domain that tells receivers what to do with mail in your name that fails SPF and DKIM. Start with p=none and rua reports, then quarantine, then reject.

  • 2 min read#App security#Web development

    A user's name became code on your server: preventing SSTI

    SSTI happens when the server's template engine evaluates user input as template code. The fix: a fixed template, user input passed as variables, and user-written templates in a sandbox.

  • 3 min read#App security#Web development

    The code that changes every 30 seconds: verify TOTP correctly

    A TOTP code comes from a shared secret and a clock. To protect your users, allow at most one time step of delay, reject a code that was already accepted, and store the secret in a protected place.

  • 2 min read#Web development#Developer tools

    A new index froze every write: CREATE INDEX CONCURRENTLY in PostgreSQL

    A plain CREATE INDEX locks the table against writes until it finishes. With CONCURRENTLY writes continue and the build takes longer, but it can't run inside a transaction, and a failure leaves an INVALID index to drop.

  • 3 min read#App security#Web development

    A folder without index.html lists every file: turn listing off

    If a folder on your site has no index file and the server is allowed to build a listing, any visitor who opens it sees every file inside. On Nginx keep autoindex off, and on Apache remove Indexes with Options -Indexes.

  • 3 min read#App security#Web development

    The blog you shut down still serves an attacker: subdomain takeover

    If you remove a hosted service but leave its CNAME record in DNS, anyone can claim the same name at that provider and publish their content on your subdomain. Remove DNS records first when you shut down, and create them last when you set up.

  • 3 min read#Developer tools#Web development

    Node.js tests without a library: node:test and node --test

    Node.js ships its own test runner, the node:test module, stable since v20.0.0. You write test(), describe() and it() as usual, and run every test file with one command: node --test.

  • 3 min read#App security#Web development

    An API without limits bills you for someone else: set a cap

    According to OWASP, an API is exposed if even one limit is missing or set wrong: execution time, memory, upload size, operations per request, records per page, or a third-party spending limit.

  • 3 min read#App security#Web development

    NEXT_PUBLIC variables reach the browser: keep secrets out

    Next.js writes the value of any environment variable that starts with NEXT_PUBLIC into the JavaScript every visitor downloads, at next build time. A secret key stays in a variable without that prefix, read on the server only.

  • 2 min read#Developer tools#Web development

    Two changes in one file, one commit? Use git add -p

    git add -p shows a file's changes hunk by hunk, and you choose what goes into the next commit and what stays out. If a hunk holds two changes, s splits it and e opens it in your editor.

  • 3 min read#Developer tools#Web development

    Two requests, one duplicate row? PostgreSQL ON CONFLICT fixes it

    INSERT with ON CONFLICT DO UPDATE in PostgreSQL inserts the row or updates the existing one in a single command, and the documentation guarantees an insert or update outcome even under high concurrency. It needs a unique index on the conflict column.

  • 3 min read#App security#Web development

    Can one GraphQL query wear out your server? Set depth limits

    In GraphQL, depth and amount can be unlimited by default, which OWASP says can lead to DoS. Set depth and amount limits and timeouts, and turn off introspection and GraphiQL in production.

  • 3 min read#App security#Web development

    Reset tokens from Math.random? How to make tokens nobody can guess

    Math.random does not give cryptographically secure random numbers, and MDN says not to use it for anything security related. For tokens and session IDs, use a secure generator like crypto.getRandomValues or crypto.randomUUID.

  • 2 min read#Developer tools#Web development

    Lost a commit after a reset? git reflog brings it back

    git reflog records every time HEAD or a branch tip changed in your local repository. So you can find a commit lost after a reset or rebase there, and put a new branch on it with one command.

  • 3 min read#Developer tools#Web development

    Index only the rows you search: PostgreSQL partial indexes

    A partial index covers part of a table, set by a WHERE condition, so it holds only the rows that match. But the query's condition must imply the index condition, and parameterized values do not work with it.

  • 2 min read#App security#Web development

    Can plain data run code on your server? Insecure deserialization

    Insecure deserialization happens when your app rebuilds objects from outside data in a language's native format. Per OWASP, avoiding native formats greatly reduces the risk, and JSON is a safe format to use instead.

  • 2 min read#App security#Web development

    Same session ID after login? How to stop session fixation

    In session fixation, the attacker plants a session ID in your browser before you log in, then uses it. Per OWASP, your app must renew the session ID after any privilege change, above all at login.

  • 2 min read#Web development#Developer tools

    Your error just says 'save failed'? Keep the reason with cause

    When you catch an error and throw a new one with a clearer message, pass the original in the cause option. Per MDN, the cause property holds the original reason, and it has worked across browsers since September 2021.

  • 2 min read#App security#Web development

    Your account page showing for another user? Cache-Control decides

    A page with a user's data must not be stored in a shared cache such as a CDN. Per MDN, private keeps it in the browser cache only, no-store stops any cache from storing it, and no-cache does not mean don't cache.

  • 3 min read#App security#Web development

    Can a filename run commands on your server? Closing command injection

    OS command injection happens when your code builds a shell command from user input, so a character like ; adds a second command. OWASP says the first fix is to not call OS commands at all and use your language's library.

  • 2 min read#App security#Web development

    Can one regex line freeze your server? How to spot ReDoS

    ReDoS sends crafted text to a regex that has repetition inside repetition, so the check tries paths that double with every character. Per OWASP, 16 characters give 65536 paths.

  • 2 min read#Web development#Developer tools

    Need every page from an async generator in one array? Array.fromAsync

    Array.fromAsync() builds an array from an async iterable and returns a Promise. Per MDN, it awaits each value one after another, while Promise.all awaits them all at once, so choose by the job.

  • 2 min read#App security#Web development

    Your site never uses the camera? Turn it off with Permissions-Policy

    The Permissions-Policy header tells the browser which features are allowed on your page and in the iframes inside it. The value () turns a feature off everywhere, so turn off the camera, microphone and location if you don't use them.

  • 2 min read#App security#Web development

    Can one DOCTYPE line in XML read your server's files? Closing XXE

    XXE happens when your XML parser resolves an external entity from a file the user sent, so it reads a file from the server and puts it in the reply. OWASP's advice: disable DTDs in the parser whenever possible.

  • 2 min read#Web development#Developer tools

    The error that never reaches catch: how Promise.try catches it in JS

    Promise.try calls your function straight away and puts its result in a promise, whether it returns a value, throws, or returns a promise. So a synchronous error reaches the same catch as an async one.

  • 2 min read#App security#Web development

    The browser rejected * with cookies? Don't echo the Origin back

    With a request that carries cookies, the browser won't accept Access-Control-Allow-Origin set to *, so many people echo back any Origin. Use an allowlist instead, plus Vary: Origin.

  • 2 min read#App security#Web development

    Does your JWT tell you how to verify it? Why you pick the algorithm

    A JWT carries the name of its signing algorithm in the alg header, and an attacker can change it to none or from RS256 to HS256. The fix: your server decides which algorithms it accepts and rejects the rest.

  • 3 min read#Web development#Developer tools

    PHP 8.6 is out: what changes in your code, from clamp() to finally

    PHP 8.6 adds partial function application, clamp() and defaults for readonly properties, deprecates return inside finally because it swallows exceptions, and makes sessions safer by default.

  • 3 min read#App security#Web development

    Can anyone post to your webhook URL? How to check the signature

    Your webhook URL is open to the whole internet, so before you trust any request, compute the HMAC signature from the secret and the raw body, and compare it with the one in the header using a constant-time comparison.

  • 2 min read#App security#Web development

    Can a strange site load your page in an iframe? Stop clickjacking

    Clickjacking uses transparent or opaque layers so the user clicks a button on another page while meaning to click the page in front. The fix starts with one header: CSP frame-ancestors, with X-Frame-Options.

  • 2 min read#App security#Privacy

    Is a user's password sitting in your logs? What must stay out of them

    Logs end up in central stores, archives and backups. The OWASP cheat sheet says passwords, tokens, session IDs and encryption keys should not go into them directly: remove, mask or hash them.

  • 2 min read#Developer tools#Web development

    Found a mistake three commits back? git commit --fixup fixes it in place

    Instead of a "small fix" commit at the end of the branch, git commit --fixup makes a commit tied to the wrong one, and git rebase --autosquash folds it in before you open the pull request.

  • 2 min read#Web development#Developer tools

    User text inside new RegExp? RegExp.escape keeps a dot a dot

    If you put text inside new RegExp without escaping it, every dot becomes "any character" and other symbols change the pattern. RegExp.escape escapes them for you, and it is Baseline 2025 in browsers.

  • 3 min read#App security#Web development

    Credential stuffing: leaked passwords that open accounts on your site

    Credential stuffing is trying email and password pairs leaked from another site on your login page. Per OWASP, the strongest defense is MFA, then layers: CAPTCHA for suspicious logins, checks against breached passwords, and user alerts.

  • 2 min read#App security#Web development

    Does your error page print a stack trace? Hide it from attackers

    A stack trace shown to the user gives an attacker your server and library names and versions, and sometimes a place to inject. The OWASP fix: a global error handler that returns a generic message, with the details in server logs only.

  • 3 min read#App security#Web development

    One JSON key that changes every object in your app: prototype pollution

    Prototype pollution happens when your code merges user JSON into a plain object, so a key like proto reaches the shared prototype. The OWASP fix: Map and Set, objects with no prototype, and frozen prototypes.

  • 2 min read#Web development#Developer tools

    A bad URL from a user crashed your code? URL.parse returns null instead

    new URL throws if the URL is invalid, so it needs try and catch. URL.parse returns null instead of throwing, so you check a URL with one if line, and it is Baseline 2024 in browsers.

  • 3 min read#App security#Web development

    Your 'forgot password' link: how to build it without a back door

    A password reset page becomes a way to take over accounts if the link can be guessed, keeps working, or is built from the Host header. The OWASP fix: one message for everyone, a long random single-use token that expires, and a fixed domain in the link.

  • 2 min read#Web development#Developer tools

    Need the first 3 of a million? map and filter on JavaScript iterators

    JavaScript iterator helpers like map, filter and take work on the iterator directly and lazily: they compute the next value only when you ask for it. So they stop once you reach the first results you need, and they even work on a sequence with no end.

  • 3 min read#App security#Web development

    A button on another site changed a user's email? How to stop CSRF

    CSRF tricks a logged-in user's browser into sending a request to your site they never meant to send. The main fix is a server-generated token checked on every state-changing request, with SameSite as an extra layer.

  • 3 min read#App security#Web development

    A download link that opens server files? How to stop path traversal

    Path traversal is when your code builds a file path from user input, so an attacker writes ../ to climb out of the folder and read other files. The fix is to never build the path from input, or to accept only known values.

  • 3 min read#Developer tools#Web development

    Mid-feature and an urgent fix lands? Use git worktree, not stash

    git worktree gives you a second working folder for the same repository, with another branch in it. You fix the urgent issue there, and your original work stays as it is, with no stash and no half-done commit.

  • 3 min read#Security updates#Web development

    Node.js November 2026 security release: which version do you need?

    Node.js fixed HTTP/2 and TLS flaws on the 22.x, 24.x and 26.x lines, rated up to High. Upgrade to 22.23.5, 24.22.3 or 26.13.1 for your line.

  • 3 min read#App security#Web development

    innerHTML blocks script tags, but a broken image still runs code

    innerHTML does not run script tags, but it runs code from other places, like onerror on an image. If the text comes from a user and you want to show it as text, use textContent.

  • 3 min read#App security#Web development

    A 3-field form made a user admin? Here is how to stop mass assignment

    Mass assignment is when your code copies every request field onto the user record, so an attacker adds a field the form never had, like isAdmin. The fix is an allowlist of fields, or a DTO that carries only what you want.

  • 3 min read#Developer tools#Web development

    Something broke and you don't know which commit? git bisect finds it

    git bisect runs a binary search between a good commit and a bad one: each step halves what is left until it reaches the first commit that broke things. With git bisect run, a script tests each step for you.

  • 4 min read#App security#Web development

    A .jpg that runs as code? How to protect file uploads

    File upload becomes a flaw when the server trusts the file name and type the browser sends. The fix is that the server decides: extensions from an allowlist, a name it generates, storage outside the webroot, and a size limit.

  • 4 min read#App security#Web development

    Your server fetches a URL the user sent? Here is how to close SSRF

    SSRF is when an attacker makes your server send a request somewhere it should never reach, such as your internal network or the cloud metadata service. The fix is an allowlist the server builds the request from, no redirect following, and checking the address after DNS.

  • 3 min read#Web development#Developer tools

    Need resolve outside the Promise? Promise.withResolvers in one line

    Promise.withResolvers() gives you a promise with its resolve and reject in one object, instead of declaring two let variables and filling them inside new Promise. Useful when an event or a callback outside the function settles it.

  • 4 min read#App security#Web development

    Does your login say the email isn't registered? It leaks your users

    A message that says whether an account exists lets anyone learn who uses your site. The fix is one message and one response time for login, password reset and sign up, plus a per-account limit on attempts.

  • 4 min read#App security#Web development

    Building SQL by joining strings? Close SQL injection with parameters

    SQL injection happens when a user's value is pasted into the query text and changes its shape. The fix is a parameterized query: the query's shape stays fixed in code, and the values reach the database separately.

  • 7 min read#Security updates#App security

    better-auth 1.7.16 fixes 12 flaws: who is exposed, and what to do?

    better-auth 1.7.16 fixes 12 flaws. The critical one only hits servers that register the expo() plugin, Electron plugin users must rotate their secrets, and web-only apps should still read the moderate list.

  • 4 min read#Security updates#Web development

    Chrome 157 has 213 security fixes: how to check you're updated

    Chrome 157 brings 213 security fixes, and 7 of them are rated Critical. Open About Google Chrome and press Relaunch if it shows, so the update applies.

  • 7 min read#Security updates#App security

    Critical Active Storage flaw: is your Rails app exposed? What now?

    Rails 8.1.4.1 and 8.0.5.2 fix 21 security issues. In the worst, an upload from an unauthenticated attacker may write files on the server when ImageMagick processes images. Update, and rotate secrets if files sit on Disk.

  • 4 min read#App security#Web development

    One number in the URL shows another user's data? Fix IDOR

    IDOR happens when the server fetches a record by the ID in the request without checking that it belongs to the user. The fix is an access check on every object, with the user taken from the session, not the request.

  • 3 min read#Web development#Developer tools

    Comparing two lists with filter and includes? Use Set methods

    JavaScript Set now has methods for intersection, difference and union, and each returns a new Set. They work in current browsers since June 2024, and the argument must be a Set or set-like object, not an array.

  • 3 min read#App security#Web development

    Can your login link send users to a fake page? Fix open redirects

    An open redirect is a page on your site that takes the destination from the request and redirects to it unchecked, so a link with your name on it lands on a phishing page. The fix: never take the URL from the user, or map it to a list on your server.

  • 3 min read#Web development#Developer tools

    Did sort() change your original array? Use toSorted instead

    sort() sorts the same array in place and returns the same reference, so the original changes. toSorted() returns a new sorted array and leaves the original as it was, and numbers still need a compare function.

  • 3 min read#App security#Privacy

    Is your password reset link leaking? Set Referrer-Policy

    Browsers send your page address with requests in the Referer header. The Referrer-Policy header decides how much of it goes out, and no-referrer removes it from sensitive pages.

  • 2 min read#App security#Web development

    Can an uploaded text file open as a page? Add nosniff

    The X-Content-Type-Options: nosniff header tells the browser to follow the Content-Type your server sent instead of guessing the type from the content, so a text/plain file with HTML in it stays text.

  • 3 min read#Web development#Developer tools

    Still grouping arrays with reduce? Use Object.groupBy

    Object.groupBy splits any array into groups in one line, based on a value a callback returns, and gives you an object with no prototype. When the key is an object rather than a string, use Map.groupBy.

  • 4 min read#Security updates#Web development

    Seven fixes in Next.js 16.4.5: who needs to update today?

    Next.js 16.4.5 and 15.5.29 close seven flaws, including a cache that can hand one tenant's data to another and HttpOnly cookies readable on Edge routes. Update, then see which ones touch your app.

  • 3 min read#App security#Web development

    Turn on CSP without breaking your site: start with Report-Only

    Ship your CSP first in the Content-Security-Policy-Report-Only header: the browser reports every script it would have blocked and the site keeps working. Fix the violations, then enforce it.

  • 3 min read#App security#Web development

    Someone found a hole in your site. How do they reach you?

    security.txt is a small text file at /.well-known/security.txt that tells a security researcher where to send the hole they found. Two fields are required, Contact and Expires, and the rest are optional.

  • 4 min read#AI#AI SEO

    Let ChatGPT and Claude find your site without training on it

    OpenAI and Anthropic each run a training bot, a search bot and a user-request bot, and each has its own name in robots.txt. Block the training bot, keep the search bot open, and your site still shows up in answers.

  • 3 min read#Web development#Developer tools

    A fetch call that never ends? Give it a timeout

    Pass fetch a signal option, AbortSignal.timeout(5000), and the request stops after 5 seconds with a TimeoutError. If you also want a cancel button, combine both signals with AbortSignal.any.

  • 4 min read#App security#Web development

    Your site runs HTTPS. Why is the first request still exposed?

    HSTS is a header that tells the browser to open your site over HTTPS only, even when someone types http. Start with one day, check every subdomain, then raise it to two years.

  • 3 min read#Web development#Developer tools

    Copied an object through JSON and lost the Date? Use structuredClone

    structuredClone makes a deep copy that keeps Date, Map, Set and circular references, which JSON.parse(JSON.stringify()) breaks. Functions and DOM nodes still can't be copied.

  • 5 min read#App security#Web development

    How to store user passwords: Argon2id with the OWASP settings

    Store a password as a slow hash, not as encrypted text: Argon2id with 19 MiB of memory, 2 iterations and 1 thread per OWASP, and let the library make the salt.

  • 4 min read#Developer tools#Web development

    Pushed a bad commit to a shared branch? Undo it with git revert

    git revert records a new commit that reverses the bad one, so history stays as it is and your teammates lose nothing. Keep git reset and push --force for branches only you use.

  • 4 min read#App security#Web development

    A CDN script can change under you: lock it with Subresource Integrity

    Add integrity and crossorigin to every script or stylesheet you load from someone else's server, and the browser refuses the file if its content does not match the hash you wrote.

  • 4 min read#App security#Web development

    How to check your session cookie: HttpOnly, Secure, SameSite

    Your session cookie is the user's pass into your site. Three attributes on the Set-Cookie line decide whether a stray script, a plain connection or another site can use it, and you can check them in five minutes.

  • 3 min read#Developer tools#Web development

    Slow PostgreSQL query? Read EXPLAIN ANALYZE without breaking your data

    EXPLAIN shows PostgreSQL's estimated plan for a query, and EXPLAIN ANALYZE actually runs it and puts the real numbers next to the estimates. Here is how to read the gap, and how to try it on an UPDATE without changing your data.

  • 2 min read#App security#Security updates

    decode-uri-component: one request can stall Node, update to 0.5.1

    decode-uri-component up to 0.5.0 takes quadratic time on malformed input, so one request of about 224 KB can block the Node.js event loop for about 20 seconds. The fix is in 0.5.1.

  • 2 min read#App security#Web development

    Vue I18n XSS: escapeParameter misses srcdoc, update to 11.4.14

    Vue I18n with escapeParameter sanitizes translations but does not handle the iframe srcdoc attribute, so a translation rendered with v-html can run script on your site. The fix is in 11.4.14.

  • 3 min read#App security#Web development

    better-auth before 1.7.7: an email is enough to take over an account

    A critical better-auth flaw lets an attacker who knows a user's email open a session in their account when Magic Link and OAuth sign-in are both on. Fixed in 1.7.7, with interim config workarounds.

  • 3 min read#WordPress#Security updates

    WordPress 7.1.4 security release: what it fixes and how to check

    WordPress 7.1.4 fixes a weakness in the upgrade process that can lead to remote code execution, plus stored XSS issues in blocks and the Interactivity API. Update now and check your version.

  • 11 min read#Security updates#Web development

    Node.js security, October 2026: what's fixed, what to run after Oct 28

    Update today to 22.23.4, 24.22.1 or 26.12.1: the update closes 10 flaws, 4 of them High, including a Brotli bug that allows remote code execution. Line 26 is planned to become LTS on October 28.

  • 9 min read#Security updates#Web development

    Next.js flaws in October 2026: which version should you upgrade to?

    If your app is on Next.js 16, go to 16.4.1 or later. If it's on 15, go to 15.5.28 and make sure sharp is 0.35.5. Then build the project and redeploy it.

  • 11 min read#Developer tools#Web development

    TypeScript 7.1 Beta: up to 1.9x faster type checking. Try it now?

    According to Microsoft's numbers, TypeScript 7.1 Beta finishes type checking 1.2 to 1.9 times faster than 7.0 and with less memory. Try it now on a separate branch, because it has a change that can break the build.

  • 10 min read#WordPress#Web development

    WordPress 7.2 Beta 1: API key storage and browser image compression

    WordPress 7.2 gives plugins an official way to store API keys encrypted instead of as plain text, and lets the browser prepare images before upload. Try Beta 1 on staging only.