<?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: devTalk</title>
    <description>The latest articles on DEV Community by devTalk (@devtalk94).</description>
    <link>https://dev.to/devtalk94</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3228626%2F5495a7f0-c356-4253-865c-b83286ec1fe4.jpg</url>
      <title>DEV Community: devTalk</title>
      <link>https://dev.to/devtalk94</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/devtalk94"/>
    <language>en</language>
    <item>
      <title>Laravel Sanctum vs Passport vs JWT: Which Auth to Use</title>
      <dc:creator>devTalk</dc:creator>
      <pubDate>Sun, 15 Nov 2026 18:12:01 +0000</pubDate>
      <link>https://dev.to/devtalk94/laravel-sanctum-vs-passport-vs-jwt-which-auth-to-use-4e0a</link>
      <guid>https://dev.to/devtalk94/laravel-sanctum-vs-passport-vs-jwt-which-auth-to-use-4e0a</guid>
      <description>&lt;p&gt;"Sanctum, Passport or JWT?" gets asked as if the three were competitors. They aren't quite. Sanctum and Passport are first-party Laravel packages. JWT is not a package at all: it's a token format (RFC 7519) that third-party Laravel packages build on. The useful question is not "which is best" but &lt;strong&gt;who is calling your API, and do you need OAuth2?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For most Laravel applications the answer is Sanctum, and Laravel's own documentation says so. This article explains why, shows what each option does with real output, and covers the cases where Passport or JWT is the right call. I ran Sanctum 4.4.0 in a Laravel 13.40 app and tested JWT behavior with &lt;code&gt;firebase/php-jwt&lt;/code&gt; 7.2.1. Passport I could only check against the documentation, and I say so where it matters.&lt;/p&gt;

&lt;h2&gt;
  
  
  The short answer
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Sanctum&lt;/th&gt;
&lt;th&gt;Passport&lt;/th&gt;
&lt;th&gt;JWT (community packages)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;What it is&lt;/td&gt;
&lt;td&gt;Lightweight first-party package: cookie auth for SPAs, plus simple API tokens&lt;/td&gt;
&lt;td&gt;First-party full OAuth2 server&lt;/td&gt;
&lt;td&gt;A signed token format; packages such as &lt;code&gt;tymon/jwt-auth&lt;/code&gt; and &lt;code&gt;php-open-source-saver/jwt-auth&lt;/code&gt; wrap it&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Best for&lt;/td&gt;
&lt;td&gt;Your own SPA, mobile app, or simple API tokens&lt;/td&gt;
&lt;td&gt;Third parties logging in through your app (OAuth2), MCP servers&lt;/td&gt;
&lt;td&gt;Stateless verification across services, if you accept the trade-offs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Revoking a token&lt;/td&gt;
&lt;td&gt;Delete a row; immediate&lt;/td&gt;
&lt;td&gt;Revoke server-side&lt;/td&gt;
&lt;td&gt;Needs server-side state (a denylist) to revoke early&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Setup weight&lt;/td&gt;
&lt;td&gt;Light&lt;/td&gt;
&lt;td&gt;Heavy (clients, keys, grants)&lt;/td&gt;
&lt;td&gt;Medium, plus your own key and lifetime decisions&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The decision flow, in order:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Is it a regular browser app on the same Laravel project? Use Laravel's built-in session authentication; you don't need any of these.&lt;/li&gt;
&lt;li&gt;Is it your own SPA or mobile app, or do you just want to hand out API tokens? &lt;strong&gt;Sanctum.&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Do outside developers need "Log in with your app" or standard OAuth2 flows, or will an MCP client connect? &lt;strong&gt;Passport.&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Do several independent services need to verify tokens without calling back to one database? Consider &lt;strong&gt;JWT&lt;/strong&gt;, and plan revocation first.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Sanctum: two things in one package
&lt;/h2&gt;

&lt;p&gt;The docs describe two separate problems Sanctum solves. First, API tokens: a simple way to issue tokens "without the complication of OAuth", stored in one database table and sent in the &lt;code&gt;Authorization&lt;/code&gt; header. Second, SPA authentication, where Sanctum doesn't use tokens at all and relies on Laravel's cookie-based session authentication instead, only for requests that come from your own SPA frontend. It is fine to use only one of the two.&lt;/p&gt;

&lt;p&gt;The setup from the docs is &lt;code&gt;php artisan install:api&lt;/code&gt;, then the &lt;code&gt;HasApiTokens&lt;/code&gt; trait on your user model:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// app/Models/User.php&lt;/span&gt;
&lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;Laravel&lt;/span&gt;\&lt;span class="nc"&gt;Sanctum&lt;/span&gt;\&lt;span class="nc"&gt;HasApiTokens&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;User&lt;/span&gt; &lt;span class="k"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Authenticatable&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;HasApiTokens&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;HasFactory&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Notifiable&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Protect routes with the &lt;code&gt;sanctum&lt;/code&gt; guard. The &lt;code&gt;abilities&lt;/code&gt; check needs its middleware alias registered once in &lt;code&gt;bootstrap/app.php&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// bootstrap/app.php, inside withMiddleware()&lt;/span&gt;
&lt;span class="nv"&gt;$middleware&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;alias&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="s1"&gt;'abilities'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; \&lt;span class="nc"&gt;Laravel&lt;/span&gt;\&lt;span class="nc"&gt;Sanctum&lt;/span&gt;\&lt;span class="nc"&gt;Http&lt;/span&gt;\&lt;span class="nc"&gt;Middleware&lt;/span&gt;\&lt;span class="nc"&gt;CheckAbilities&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="k"&gt;class&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s1"&gt;'ability'&lt;/span&gt;   &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; \&lt;span class="nc"&gt;Laravel&lt;/span&gt;\&lt;span class="nc"&gt;Sanctum&lt;/span&gt;\&lt;span class="nc"&gt;Http&lt;/span&gt;\&lt;span class="nc"&gt;Middleware&lt;/span&gt;\&lt;span class="nc"&gt;CheckForAnyAbility&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="k"&gt;class&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// routes/api.php&lt;/span&gt;
&lt;span class="nc"&gt;Route&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;middleware&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'auth:sanctum'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'/user'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Request&lt;/span&gt; &lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;user&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;only&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'id'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'name'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'email'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nc"&gt;Route&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;middleware&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'auth:sanctum'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'abilities:orders:read'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'/orders'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'orders'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nc"&gt;Route&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;middleware&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'auth:sanctum'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'abilities:orders:write'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'/orders'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'created'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nc"&gt;Route&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;middleware&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'auth:sanctum'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'/logout'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Request&lt;/span&gt; &lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;user&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;currentAccessToken&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;delete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'ok'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Issuing tokens is one call. This is the pattern from the docs for a mobile login endpoint, which checks the credentials and returns a token named after the device:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nc"&gt;Route&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'/sanctum/token'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Request&lt;/span&gt; &lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;validate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="s1"&gt;'email'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'required|email'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s1"&gt;'password'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'required'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s1"&gt;'device_name'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'required'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="nv"&gt;$user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'email'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;first&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt; &lt;span class="nv"&gt;$user&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt; &lt;span class="nc"&gt;Hash&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;check&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;password&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;password&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="nc"&gt;ValidationException&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;withMessages&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="s1"&gt;'email'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'The provided credentials are incorrect.'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;createToken&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;device_name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;plainTextToken&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  What Sanctum does, as tested
&lt;/h3&gt;

&lt;p&gt;I created a user and three tokens: one with all abilities, one limited to &lt;code&gt;orders:read&lt;/code&gt;, and one that expires after two seconds. This is what is stored:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;full      abilities=["*"]            expires_at=NULL                 stored=b702e54970e2...
readonly  abilities=["orders:read"]  expires_at=NULL                 stored=4018077e2989...
short     abilities=["*"]            expires_at=2026-11-11 15:05:31  stored=921fc96a0f45...
plain-text token shown to user: 1|R1vlLbpDsiZM...
sha256(secret part) matches stored hash: true
config sanctum.expiration = NULL
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three facts are visible here. The user's token looks like &lt;code&gt;1|random&lt;/code&gt;, not a JWT. The database holds only a SHA-256 hash, which matches the docs, so the plain text exists only at creation time. And &lt;code&gt;expires_at&lt;/code&gt; is &lt;code&gt;NULL&lt;/code&gt; with &lt;code&gt;sanctum.expiration&lt;/code&gt; unset: the docs confirm that by default Sanctum tokens never expire and can only be invalidated by revoking them. Set an expiration unless you really want that.&lt;/p&gt;

&lt;p&gt;The requests, against a local server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ curl /api/user   (no token)
{"message":"Unauthenticated."}  [401]

$ curl /api/user   (full token)
{"id":1,"name":"Ann","email":"ann@example.test"}  [200]

$ GET /api/orders  (readonly token, needs orders:read)
{"orders":[]}  [200]

$ POST /api/orders (readonly token, needs orders:write)
{"message":"Invalid ability provided."}  [403]

$ POST /api/orders (full token)
{"created":true}  [200]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(With debug mode on, the 403 response also carries a stack trace; I show only the message.) Revocation takes effect on the very next request, because the token's row is gone:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ POST /api/logout (full token)
{"ok":true}  [200]

$ GET /api/user    (same token again)
{"message":"Unauthenticated."}  [401]

$ GET /api/user    (short token, 2s lifetime, age ~3s)
{"message":"Unauthenticated."}  [401]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Set a global lifetime in &lt;code&gt;config/sanctum.php&lt;/code&gt; (&lt;code&gt;'expiration'&lt;/code&gt; is in minutes) or per token, as the docs show: &lt;code&gt;createToken('name', ['*'], now()-&amp;gt;plus(weeks: 1))&lt;/code&gt;. Add the documented &lt;code&gt;sanctum:prune-expired --hours=24&lt;/code&gt; command to your scheduler so old rows don't pile up.&lt;/p&gt;

&lt;p&gt;For a first-party SPA, the docs say SPA and API must share a top-level domain (subdomains are fine). You configure stateful domains, call &lt;code&gt;/sanctum/csrf-cookie&lt;/code&gt; first, then log in. In that mode no token is stored in the browser, which removes a whole class of "where do I keep the token" questions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Passport: when you actually need OAuth2
&lt;/h2&gt;

&lt;p&gt;Passport is a full OAuth2 server. The docs put it plainly: if your application absolutely needs to support OAuth2, use Passport; to authenticate a single-page application or mobile application, or to issue API tokens, use Sanctum. The authentication page adds that most applications don't need the complexity of the OAuth2 specification, and that Passport is the choice if you're building an MCP server that AI clients will connect to, since those clients typically expect OAuth.&lt;/p&gt;

&lt;p&gt;What you get, per the Passport documentation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Authorization code grant, and authorization code with PKCE for SPAs and mobile apps.&lt;/li&gt;
&lt;li&gt;Client credentials for machine-to-machine access, and device authorization for browserless devices.&lt;/li&gt;
&lt;li&gt;Scopes, refresh tokens and personal access tokens.&lt;/li&gt;
&lt;li&gt;The password and implicit grants are marked deprecated: "We no longer recommend" them.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Setup is heavier: &lt;code&gt;php artisan install:api --passport&lt;/code&gt; runs migrations for OAuth clients and tokens and generates encryption keys, and you then create clients with &lt;code&gt;passport:client&lt;/code&gt; variants. By default Passport issues long-lived access tokens that expire after one year, which you can shorten with &lt;code&gt;Passport::tokensExpireIn()&lt;/code&gt; and related methods. I did not install Passport for this article, so none of that was run; it is all from the documentation.&lt;/p&gt;

&lt;p&gt;If your use of Passport amounts to issuing personal access tokens to your own users, the docs themselves suggest considering Sanctum instead.&lt;/p&gt;

&lt;h2&gt;
  
  
  JWT: a token format, not a package choice
&lt;/h2&gt;

&lt;p&gt;A JWT carries its claims inside the token and is signed, so a server can verify it without a database lookup. RFC 7519 defines the registered claims: &lt;code&gt;iss&lt;/code&gt; (issuer), &lt;code&gt;sub&lt;/code&gt; (subject), &lt;code&gt;aud&lt;/code&gt; (audience), &lt;code&gt;exp&lt;/code&gt; (expiry, after which the token must not be accepted), &lt;code&gt;nbf&lt;/code&gt;, &lt;code&gt;iat&lt;/code&gt; and &lt;code&gt;jti&lt;/code&gt; (a unique ID). Laravel doesn't ship a JWT guard. The common packages are &lt;code&gt;tymon/jwt-auth&lt;/code&gt; and its fork &lt;code&gt;php-open-source-saver/jwt-auth&lt;/code&gt;. When I read their repositories on 11 November 2026, both allowed Laravel 13 in &lt;code&gt;composer.json&lt;/code&gt; and had commits within the previous few weeks (Tymon's latest tag was 2.3.1; the fork's was v2.10.0 and requires PHP 8.3 or newer). That tells you they're maintained, not that they're right for you.&lt;/p&gt;

&lt;p&gt;To see how JWTs behave without any framework, I ran the plain &lt;code&gt;firebase/php-jwt&lt;/code&gt; library:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;header alg: HS256
payload is only encoded, not encrypted: {"iss":"https://api.example.test","aud":"example-mobile-app","sub":"42","iat":N,"exp":N,"jti":"tok-001"}

1 valid token                     accepted, sub=42
2 payload edited                  Firebase\JWT\SignatureInvalidException: Signature verification failed
3 alg "none" token                UnexpectedValueException: Algorithm not supported
4 wrong key                       Firebase\JWT\SignatureInvalidException: Signature verification failed
5 after "logout", no denylist     accepted
6 same token, jti denylisted      RuntimeException: token revoked (jti on denylist)
7 after exp (3s later)            Firebase\JWT\ExpiredException: Expired token
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(&lt;code&gt;iat&lt;/code&gt; and &lt;code&gt;exp&lt;/code&gt; are replaced by &lt;code&gt;N&lt;/code&gt; because they are timestamps that change on every run.) What this shows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The payload is readable by anyone holding the token.&lt;/strong&gt; It's base64-encoded, not encrypted. Never put secrets or personal data in it that the client shouldn't see.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tampering is caught.&lt;/strong&gt; Editing the payload (line 2) or using the wrong key (line 4) fails signature verification.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The&lt;/strong&gt;&lt;code&gt;none&lt;/code&gt;&lt;strong&gt;algorithm is rejected, because the caller pinned the algorithm.&lt;/strong&gt; Passing the expected algorithm in &lt;code&gt;new Key($secret, 'HS256')&lt;/code&gt; is what protects you. RFC 8725, the JWT best-practices document, makes this the first rule: libraries must let the caller specify the supported algorithms, and applications should not trust the token's own &lt;code&gt;alg&lt;/code&gt; header.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Logout does nothing by itself (line 5).&lt;/strong&gt; The signature and expiry are all the server checks, so a stolen or "logged out" token is accepted until &lt;code&gt;exp&lt;/code&gt;. To revoke early you need server-side state, such as the &lt;code&gt;jti&lt;/code&gt; denylist in line 6. At that point you have given up part of the "no database lookup" advantage.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Expiry works (line 7)&lt;/strong&gt;, which is why access-token lifetimes should be short.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;RFC 8725 also recommends validating the issuer and audience and using explicit typing; my &lt;code&gt;$check&lt;/code&gt; function does the first two by hand. Whatever package you choose, confirm it validates &lt;code&gt;iss&lt;/code&gt;, &lt;code&gt;aud&lt;/code&gt; and &lt;code&gt;exp&lt;/code&gt; and that your key is long and random. For a first-party app that only talks to your own Laravel backend, JWT adds complexity that Sanctum avoids.&lt;/p&gt;

&lt;p&gt;A fair design comparison, labelled as reasoning rather than a benchmark: Sanctum looks the token up in your database on each request (that's how revocation can be immediate), while a JWT can be verified from the signature alone. For one Laravel app that difference rarely matters. It matters more when many independent services must verify tokens without sharing a database.&lt;/p&gt;

&lt;h2&gt;
  
  
  Which one for which situation
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Your situation&lt;/th&gt;
&lt;th&gt;Use&lt;/th&gt;
&lt;th&gt;Why&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Server-rendered Laravel app&lt;/td&gt;
&lt;td&gt;Built-in session auth&lt;/td&gt;
&lt;td&gt;No tokens needed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Your own SPA on the same top-level domain&lt;/td&gt;
&lt;td&gt;Sanctum (cookie mode)&lt;/td&gt;
&lt;td&gt;No token stored in the browser&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Your own mobile app&lt;/td&gt;
&lt;td&gt;Sanctum tokens&lt;/td&gt;
&lt;td&gt;Simple, revocable per device, with abilities&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Public API where customers generate their own keys&lt;/td&gt;
&lt;td&gt;Sanctum tokens&lt;/td&gt;
&lt;td&gt;Hashed storage, abilities, easy revocation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"Log in with our app" for third-party developers&lt;/td&gt;
&lt;td&gt;Passport&lt;/td&gt;
&lt;td&gt;That is what OAuth2 is for&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Server-to-server access with client credentials&lt;/td&gt;
&lt;td&gt;Passport&lt;/td&gt;
&lt;td&gt;Standard grant for machine access&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;MCP server for AI clients&lt;/td&gt;
&lt;td&gt;Passport&lt;/td&gt;
&lt;td&gt;The Laravel docs recommend it; MCP clients typically expect OAuth&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Many separate services must verify tokens independently&lt;/td&gt;
&lt;td&gt;JWT, or an external identity provider&lt;/td&gt;
&lt;td&gt;Stateless verification; plan revocation and key rotation&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Common mistakes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Installing Passport for a first-party mobile app.&lt;/strong&gt; You pay for OAuth2 you don't use. The docs steer you to Sanctum.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Leaving Sanctum tokens non-expiring.&lt;/strong&gt; It's the default. Set &lt;code&gt;sanctum.expiration&lt;/code&gt; or a per-token expiry and prune old rows.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Using tokens for a same-domain SPA.&lt;/strong&gt; Sanctum's cookie mode exists so the browser doesn't hold a bearer token.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Granting&lt;/strong&gt;&lt;code&gt;['*']&lt;/code&gt;&lt;strong&gt;to every token.&lt;/strong&gt; Give tokens the abilities they need; you saw a limited token get a 403.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Long-lived JWTs with no revocation plan.&lt;/strong&gt; Keep access tokens short and decide how you'd cut off a stolen one.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Trusting the&lt;/strong&gt;&lt;code&gt;alg&lt;/code&gt;&lt;strong&gt;header.&lt;/strong&gt; Pin the algorithm on verification.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Putting sensitive data in a JWT payload.&lt;/strong&gt; Signed is not secret.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Treating password and implicit grants as current.&lt;/strong&gt; Passport's docs call them deprecated.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Alternatives
&lt;/h2&gt;

&lt;p&gt;Built-in session authentication covers a monolithic app. The Laravel docs also note that the cookie-based libraries and the token packages aren't mutually exclusive, so an app can serve a web UI and an API at once. If your organization already runs an identity provider (Keycloak, Auth0, or similar), validating its JWTs in Laravel can be the better design than building your own issuer; I haven't evaluated those products here.&lt;/p&gt;

&lt;h2&gt;
  
  
  Related Dev Talk articles
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dev-talk.com/post/common-api-design-mistakes" rel="noopener noreferrer"&gt;10 Common API Design Mistakes Developers Make&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev-talk.com/post/laravel-env-configuration-env-vs-config" rel="noopener noreferrer"&gt;Laravel .env Configuration: env() vs config() Explained&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev-talk.com/post/laravel-scheduler-not-running-cron-fixes" rel="noopener noreferrer"&gt;Laravel Scheduler Not Running: Cron and schedule:run Fixes&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Frequently asked questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Is Sanctum a JWT implementation?
&lt;/h3&gt;

&lt;p&gt;No. In the test, the token looked like &lt;code&gt;1|random-string&lt;/code&gt;, and the database stored only its SHA-256 hash. Authentication is a lookup, not a signature check.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can I revoke a JWT?
&lt;/h3&gt;

&lt;p&gt;Not by itself. You need server-side state, such as a denylist of token IDs, or very short lifetimes with refresh tokens. Both packages mentioned above have a token blacklist in their source (a &lt;code&gt;TokenBlacklistedException&lt;/code&gt; and blacklist handling in &lt;code&gt;JWT.php&lt;/code&gt;); check their docs for how entries are stored and for how long.&lt;/p&gt;

&lt;h3&gt;
  
  
  Do Sanctum tokens expire?
&lt;/h3&gt;

&lt;p&gt;Only if you configure it. The default is no expiry. Use &lt;code&gt;sanctum.expiration&lt;/code&gt; (minutes) for a global limit or pass an expiry date to &lt;code&gt;createToken&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can I use Sanctum and Passport in the same app?
&lt;/h3&gt;

&lt;p&gt;The Laravel docs say the cookie-based authentication and the token packages are not mutually exclusive. I did not test running both packages together, and most apps only need one.&lt;/p&gt;

&lt;h3&gt;
  
  
  What about refresh tokens?
&lt;/h3&gt;

&lt;p&gt;Passport issues refresh tokens as part of OAuth2. Sanctum's documentation doesn't describe refresh tokens: you issue a new token or let the user log in again. Both JWT packages I read have a &lt;code&gt;refresh()&lt;/code&gt; method in their source; check how the one you choose handles it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://laravel.com/docs/13.x/sanctum" rel="noopener noreferrer"&gt;Laravel documentation: Sanctum&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://laravel.com/framework/docs/passport" rel="noopener noreferrer"&gt;Laravel documentation: Passport&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://laravel.com/docs/13.x/authentication" rel="noopener noreferrer"&gt;Laravel documentation: Authentication&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://rfc-editor.org/rfc/rfc7519" rel="noopener noreferrer"&gt;RFC 7519: JSON Web Token (JWT)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://rfc-editor.org/rfc/rfc8725.html" rel="noopener noreferrer"&gt;RFC 8725: JSON Web Token Best Current Practices&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/laravel/sanctum" rel="noopener noreferrer"&gt;laravel/sanctum on GitHub&lt;/a&gt;, &lt;a href="https://github.com/firebase/php-jwt" rel="noopener noreferrer"&gt;firebase/php-jwt on GitHub&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://dev-talk.com/post/laravel-sanctum-vs-passport-vs-jwt" rel="noopener noreferrer"&gt;DEV Talk&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>sanctum</category>
      <category>passport</category>
      <category>jwt</category>
    </item>
    <item>
      <title>Git Security Release: 6 Vulnerabilities and CVE-2026-111760</title>
      <dc:creator>devTalk</dc:creator>
      <pubDate>Sun, 15 Nov 2026 14:31:33 +0000</pubDate>
      <link>https://dev.to/devtalk94/git-security-release-6-vulnerabilities-and-cve-2026-111760-1910</link>
      <guid>https://dev.to/devtalk94/git-security-release-6-vulnerabilities-and-cve-2026-111760-1910</guid>
      <description>&lt;p&gt;&lt;em&gt;Last updated: 15 November 2026. This is a recent security release; see the&lt;/em&gt;&lt;em&gt;update log&lt;/em&gt;&lt;em&gt;and check the Git announcement for changes.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;On 10 November 2026 the Git project released fixes for six vulnerabilities. One of them is the kind that makes developers nervous: cloning a malicious repository with &lt;code&gt;git clone --recurse-submodules&lt;/code&gt; can lead to attacker-controlled code running on your machine. The other five are a mix of file-write, memory-corruption and denial-of-service bugs that matter most to servers and tools that handle untrusted repositories.&lt;/p&gt;

&lt;p&gt;This article walks through all six, says which ones you should worry about, shows how to check your Git version (with a script I tested), and lists what you can do until you have patched. A caution up front: the Git announcement gives no severity scores, and I could not run the exploits, so the severity talk below is based on what the maintainers wrote.&lt;/p&gt;

&lt;h2&gt;
  
  
  The short version
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Fixed in:&lt;/strong&gt; Git 2.56.1 and the maintenance releases 2.55.1, 2.54.1, 2.53.1, 2.52.1, 2.51.3 and 2.50.2.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Affected:&lt;/strong&gt; per the announcement, all versions back to v2.27.0. Versions older than 2.50 are no longer serviced upstream.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The serious one:&lt;/strong&gt; CVE-2026-111760, code execution during a recursive clone of an attacker-controlled repository.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Exploited in the wild:&lt;/strong&gt; none of the coverage I read reports it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Action:&lt;/strong&gt; update Git, and update every tool that bundles its own copy of Git.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The six vulnerabilities at a glance
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;CVE&lt;/th&gt;
&lt;th&gt;What happens&lt;/th&gt;
&lt;th&gt;Triggered by&lt;/th&gt;
&lt;th&gt;Impact (per the announcement)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;CVE-2026-111760&lt;/td&gt;
&lt;td&gt;Integer truncation in path handling lets a crafted path be written as &lt;code&gt;.git&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;git clone --recurse-submodules&lt;/code&gt; of an attacker's repository&lt;/td&gt;
&lt;td&gt;Remote code execution&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CVE-2026-113408&lt;/td&gt;
&lt;td&gt;Unvalidated &lt;code&gt;HEAD&lt;/code&gt; symref from a server (protocol v2) with &lt;code&gt;..&lt;/code&gt; segments&lt;/td&gt;
&lt;td&gt;Cloning from a malicious server, then a later operation like &lt;code&gt;git commit&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;A ref file written outside the refs directory&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CVE-2026-114467&lt;/td&gt;
&lt;td&gt;More than two GPG signatures overflow a fixed array in &lt;code&gt;remove_signature()&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Merging a tag whose message has more than two PGP signatures&lt;/td&gt;
&lt;td&gt;Stack corruption: denial of service, a risk for forges&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CVE-2026-114469&lt;/td&gt;
&lt;td&gt;Binary patch size check looks only at the compressed size&lt;/td&gt;
&lt;td&gt;Applying an attacker's binary patch (for example &lt;code&gt;git apply&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;Out-of-bounds read and crash&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CVE-2026-105437&lt;/td&gt;
&lt;td&gt;Size overflow in the three-way merge buffer, with many conflicts and a large &lt;code&gt;conflict-marker-size&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Any textual three-way merge: merge, rebase, cherry-pick, merge-tree&lt;/td&gt;
&lt;td&gt;Heap buffer overflow; on forges that read attributes from trees, a risk for anyone who can push and request a merge&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CVE-2026-114466&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;fast-import&lt;/code&gt; features &lt;code&gt;rewrite-submodules-from/to&lt;/code&gt; and &lt;code&gt;export-pack-edges&lt;/code&gt; access arbitrary files&lt;/td&gt;
&lt;td&gt;Feeding an untrusted fast-import stream&lt;/td&gt;
&lt;td&gt;Arbitrary file read (content can leak in error messages) and append&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  CVE-2026-111760: how a clone can run code
&lt;/h2&gt;

&lt;p&gt;The Git maintainers describe the bug like this. Git stores the length of a path name in a 32-bit field, but computes it as a larger type. A path of about 232 bytes makes the stored length wrap around to 4. Path validation looks at the full, long name and finds nothing wrong. Checkout, however, writes only the first 4 bytes, and those 4 bytes can be &lt;code&gt;.git&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If the entry is a symlink, it can replace the &lt;code&gt;.git&lt;/code&gt; file of a submodule. Normally a submodule's &lt;code&gt;.git&lt;/code&gt; is a small file that points to the real repository directory. Pointing it at a directory the attacker controls, one that holds hooks or configuration, means Git will later run attacker-specified code. Git refuses to replace a &lt;code&gt;.git&lt;/code&gt; directory with a symlink, but a freshly cloned submodule's &lt;code&gt;.git&lt;/code&gt; is a file, and The Hacker News notes that this check does not block that case.&lt;/p&gt;

&lt;p&gt;Requirements, per the announcement:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You clone an attacker-controlled repository with &lt;code&gt;--recurse-submodules&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Such a repository fails the &lt;code&gt;LARGE_PATHNAME&lt;/code&gt; and &lt;code&gt;TREE_NOT_SORTED&lt;/code&gt; fsck checks, so major forges would be expected to refuse a push of it. But a malicious &lt;code&gt;.gitmodules&lt;/code&gt; in a normal-looking repository that points at one is enough.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That second point is the practical risk. The repository you clone looks innocent. The submodule it pulls in is the weapon. Credit for the report goes to Robert Chen. A secondary source rates it High with a CVSS base score of 8.0; the Git announcement itself gives no score.&lt;/p&gt;

&lt;h2&gt;
  
  
  Who is at risk
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Developers&lt;/strong&gt; who clone unfamiliar repositories (open source, a contractor's repo, a "try this" link) with &lt;code&gt;--recurse-submodules&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CI systems&lt;/strong&gt; that check out pull requests from forks or arbitrary repositories with recursive submodules, especially when the job has secrets or deploy credentials.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Code hosting and review tools&lt;/strong&gt; that merge, apply patches or import repositories for users. The merge, patch and signature bugs mostly matter here, and GitLab is cited as saying that servers running &lt;code&gt;git merge-tree&lt;/code&gt; are most exposed to CVE-2026-105437.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Anything that bundles its own Git&lt;/strong&gt;: GUI clients, IDEs, deployment tools, and container images. Updating the Git on your PATH does not update those.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Check your version
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git --version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Compare it with the fixed releases. This script does that for you. It knows the seven fixed releases and prints a clear verdict:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;
&lt;span class="c"&gt;# Usage: ./chk_git.sh                (checks the git on PATH)&lt;/span&gt;
&lt;span class="c"&gt;#        ./chk_git.sh "git version 2.54.0"   (checks a version string)&lt;/span&gt;
&lt;span class="c"&gt;# Fixed upstream releases for the November 2026 security release:&lt;/span&gt;
&lt;span class="c"&gt;#   2.50.2 2.51.3 2.52.1 2.53.1 2.54.1 2.55.1 2.56.1&lt;/span&gt;
&lt;span class="kd"&gt;declare&lt;/span&gt; -A &lt;span class="nv"&gt;FIXED&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;2.50&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;2 &lt;span class="o"&gt;[&lt;/span&gt;2.51&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;3 &lt;span class="o"&gt;[&lt;/span&gt;2.52&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1 &lt;span class="o"&gt;[&lt;/span&gt;2.53&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1 &lt;span class="o"&gt;[&lt;/span&gt;2.54&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1 &lt;span class="o"&gt;[&lt;/span&gt;2.55&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1 &lt;span class="o"&gt;[&lt;/span&gt;2.56&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1 &lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nv"&gt;raw&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"${1:-$(git --version)}"&lt;/span&gt;
&lt;span class="nv"&gt;ver&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"$raw"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; grep -oE &lt;span class="s1"&gt;'[0-9]+\.[0-9]+\.[0-9]+'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; head -1&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt; -z &lt;span class="s2"&gt;"$ver"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"could not parse: $raw"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;exit&lt;/span&gt; 2&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="nv"&gt;IFS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;. &lt;span class="nb"&gt;read&lt;/span&gt; -r maj min pat &lt;span class="o"&gt;&amp;lt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s2"&gt;"$ver"&lt;/span&gt;
&lt;span class="nv"&gt;series&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"$maj.$min"&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"$maj"&lt;/span&gt; -gt 2 &lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"$maj"&lt;/span&gt; -eq 2 &lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"$min"&lt;/span&gt; -gt 56 &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"$ver: newer than the 2.56 series, assumed to include the fixes"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;exit&lt;/span&gt; 0
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; -z &lt;span class="s2"&gt;"${FIXED[$series]:-}"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"$ver: series $series gets no upstream maintenance release for this advisory."&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"   Distribution packages may carry backported fixes: check your vendor's security notice."&lt;/span&gt;
  &lt;span class="nb"&gt;exit&lt;/span&gt; 1
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"$pat"&lt;/span&gt; -ge &lt;span class="s2"&gt;"${FIXED[$series]}"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"$ver: includes the fix (needs $series.${FIXED[$series]} or newer)"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;exit&lt;/span&gt; 0
&lt;span class="k"&gt;else&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"$ver: VULNERABLE. Update to $series.${FIXED[$series]} or newer (2.56.1 is the newest line)"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;exit&lt;/span&gt; 1
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Results from my tests of the script:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2.50.1: VULNERABLE. Update to 2.50.2 or newer (2.56.1 is the newest line)
2.50.2: includes the fix (needs 2.50.2 or newer)
2.54.0: VULNERABLE. Update to 2.54.1 or newer (2.56.1 is the newest line)
2.54.1: includes the fix (needs 2.54.1 or newer)
2.56.0: VULNERABLE. Update to 2.56.1 or newer (2.56.1 is the newest line)
2.56.1: includes the fix (needs 2.56.1 or newer)
2.57.0: newer than the 2.56 series, assumed to include the fixes
2.43.0: series 2.43 gets no upstream maintenance release for this advisory.
   Distribution packages may carry backported fixes: check your vendor's security notice.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It also handled suffixes such as &lt;code&gt;2.56.0.windows.4&lt;/code&gt; and &lt;code&gt;2.39.5 (Apple Git-154)&lt;/code&gt;, and exits with an error for input it cannot parse. The Git on the machine where I tested was 2.43.0, a distribution package. That is the case the script cannot settle: Linux distributions often backport security fixes into older version numbers, so an old number there does not prove you are vulnerable, and a new-looking number from an unofficial source does not prove you are safe. Check your distribution's security notice for these CVEs.&lt;/p&gt;

&lt;h3&gt;
  
  
  Windows, macOS and bundled copies
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Git for Windows:&lt;/strong&gt; my sources disagree. One secondary report says Git for Windows 2.56.1 was released on 11 November, while The Hacker News says that, when it checked, no fixed Git for Windows version was out, and the releases page I fetched listed 2.56.0.windows.4 as the latest. Check the Git for Windows releases page yourself.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GitHub:&lt;/strong&gt; per GitHub's statement quoted in the coverage, github.com and GitHub Enterprise Cloud are patched; GitHub Enterprise Server fixes are in 3.19.15, 3.20.11, 3.21.9 and 3.22.4; patched builds of GitHub Desktop and the Copilot app are being coordinated, with Codespaces and Actions to follow.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bundled Git:&lt;/strong&gt; any application that ships its own Git needs its own update. Look at the vendor's release notes.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Until you can update
&lt;/h2&gt;

&lt;p&gt;The Git maintainers' advice, as quoted by GitHub's Elijah Newren, is to clone only from trusted servers and avoid recursive clones of untrusted repositories. These precautions do not replace installing the fixes. Some concrete ways to follow it:&lt;/p&gt;

&lt;h3&gt;
  
  
  Clone first, look, then fetch submodules
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://example.com/someone/project.git
&lt;span class="nb"&gt;cd&lt;/span&gt; project
git config -f .gitmodules --get-regexp &lt;span class="s1"&gt;'^submodule\..*\.url$'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;submodule.vendor/libs.url ../libs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A plain clone leaves submodule directories empty (I confirmed: zero files in &lt;code&gt;vendor/libs&lt;/code&gt; after cloning). The second command lists every URL the repository wants to fetch. If a submodule points at a host you don't recognize, stop there. If they look fine:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git submodule update --init --recursive
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I tested this workflow with local repositories: the plain clone fetched nothing, the URL listing worked, and the update checked out the submodule. This reduces the chance of fetching a submodule you did not intend to, but it is a manual review step, not a guarantee that a submodule you decide to trust is safe, and it does not remove the underlying flaw.&lt;/p&gt;

&lt;h3&gt;
  
  
  Be careful with untrusted merges and patches
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Don't merge tags or branches from sources you don't trust (CVE-2026-114467, CVE-2026-105437).&lt;/li&gt;
&lt;li&gt;Don't &lt;code&gt;git apply&lt;/code&gt; binary patches from unknown senders (CVE-2026-114469).&lt;/li&gt;
&lt;li&gt;Don't feed &lt;code&gt;git fast-import&lt;/code&gt; streams from untrusted sources (CVE-2026-114466).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  A workaround for the merge overflow: conflict-marker-size
&lt;/h3&gt;

&lt;p&gt;For CVE-2026-105437, The Hacker News cites GitLab suggesting a workaround: set &lt;code&gt;conflict-marker-size=7&lt;/code&gt; in each repository's &lt;code&gt;info/attributes&lt;/code&gt; file. The reason this can work is that the dangerous input is the attacker-controlled attribute value, and &lt;code&gt;info/attributes&lt;/code&gt; overrides the attributes committed in the repository. I tested the precedence with a small repository whose committed &lt;code&gt;.gitattributes&lt;/code&gt; sets the marker size to 20:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s1"&gt;'* conflict-marker-size=7\n'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; .git/info/attributes
git check-attr conflict-marker-size -- f.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;f.txt: conflict-marker-size: 7
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Before that file existed, a conflicted merge produced 20-character markers (&lt;code&gt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; HEAD&lt;/code&gt;); afterwards it produced the standard 7. So the override works as described. What I could not do is confirm that the override prevents the overflow itself, since I cannot trigger that bug. For a hosting service, this is a stopgap while you roll out a patched Git, not a replacement for it.&lt;/p&gt;

&lt;h3&gt;
  
  
  The fast-import change can break scripts
&lt;/h3&gt;

&lt;p&gt;The fix for CVE-2026-114466 turns the risky &lt;code&gt;fast-import&lt;/code&gt; features off unless &lt;code&gt;--allow-unsafe-features&lt;/code&gt; is passed. The Git announcement calls this a backwards-incompatible change with minimal expected impact, since the features mostly serve import/export remote helpers. If you run such a tool after updating and it fails, that flag is why. Add it only when the program generating the stream is trusted.&lt;/p&gt;

&lt;h2&gt;
  
  
  A hardening baseline worth adopting
&lt;/h2&gt;

&lt;p&gt;These are my recommendations, not part of the announcement:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Don't run &lt;code&gt;git clone --recurse-submodules&lt;/code&gt; as a reflex. Make recursive fetching a deliberate step for repositories you trust.&lt;/li&gt;
&lt;li&gt;In CI, don't check out untrusted forks with recursive submodules in jobs that hold secrets. Separate "build the pull request" from "deploy" and keep credentials out of the first job.&lt;/li&gt;
&lt;li&gt;Inventory the tools on build agents and laptops that bundle Git, and include them in your patching process.&lt;/li&gt;
&lt;li&gt;Keep Git on servers that handle user repositories on a patch schedule of days, not months.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Common mistakes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Updating the system Git but leaving an IDE, GUI client or container image with an old bundled copy.&lt;/li&gt;
&lt;li&gt;Assuming "2.4x is old, so I'm vulnerable" or "my distro updated, so I'm safe" without reading the vendor notice.&lt;/li&gt;
&lt;li&gt;Treating a forge's fsck checks as protection when the real payload is a malicious &lt;code&gt;.gitmodules&lt;/code&gt; in an ordinary-looking repository.&lt;/li&gt;
&lt;li&gt;Ignoring the five non-RCE bugs on servers that merge or apply patches for users.&lt;/li&gt;
&lt;li&gt;Applying &lt;code&gt;--allow-unsafe-features&lt;/code&gt; everywhere to make a broken script work again.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Related Dev Talk articles
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dev-talk.com/post/red-hat-quay-cve-2026-123710" rel="noopener noreferrer"&gt;Critical Red Hat Quay Flaw (CVE-2026-123710): Unauthenticated Registry Takeover and What to Do&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev-talk.com/post/cursor-claude-code-extension-backdoor-what-to-check" rel="noopener noreferrer"&gt;Malicious Claude Code Extension in the Cursor Marketplace: What Happened and How to Check Your Machine&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev-talk.com/post/github-actions-laravel-deploy-ssh-releases-rollback" rel="noopener noreferrer"&gt;GitHub Actions for Laravel, Part 3: Deploy over SSH with Releases and Rollback&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Frequently asked questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Which Git versions are fixed?
&lt;/h3&gt;

&lt;p&gt;2.56.1, 2.55.1, 2.54.1, 2.53.1, 2.52.1, 2.51.3 and 2.50.2. Anything older is no longer serviced upstream; your distribution may have its own patched package.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can a normal git clone run malicious code?
&lt;/h3&gt;

&lt;p&gt;For CVE-2026-111760 the announcement describes a recursive clone (&lt;code&gt;--recurse-submodules&lt;/code&gt;) of an attacker-controlled repository. A plain clone did not fetch submodules in my test. Check the other five for the operations they need (merging, applying patches and so on).&lt;/p&gt;

&lt;h3&gt;
  
  
  Is it being exploited?
&lt;/h3&gt;

&lt;p&gt;None of the sources I read report exploitation. Details are public, so patch anyway.&lt;/p&gt;

&lt;h3&gt;
  
  
  Do I need to update GitHub Desktop, VS Code or other tools?
&lt;/h3&gt;

&lt;p&gt;If they bundle their own Git, yes, once the vendor releases an update. Whether a given tool bundles Git or uses the one on your system differs by tool, and I did not check individual products, so read each vendor's release notes.&lt;/p&gt;

&lt;h3&gt;
  
  
  Does disabling submodules fully protect me?
&lt;/h3&gt;

&lt;p&gt;It removes the route for CVE-2026-111760, but the other bugs have other triggers. Update Git.&lt;/p&gt;

&lt;h2&gt;
  
  
  update log
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;15 November 2026:&lt;/strong&gt; first version.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;To recheck on each update:&lt;/strong&gt; the Git announcement and release notes, the Git for Windows releases page, your distribution's security notice, and GitHub's client rollout.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.openwall.com/lists/oss-security/2026/11/11/10" rel="noopener noreferrer"&gt;oss-security: git v2.56.1 and older maintenance releases fix six vulnerabilities&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.helpnetsecurity.com/2026/11/11/git-project-security-updates/" rel="noopener noreferrer"&gt;Help Net Security: Git fixes six vulnerabilities, including code execution during recursive clones&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://thehackernews.com/2026/11/git-patches-flaw-that-lets-malicious.html" rel="noopener noreferrer"&gt;The Hacker News: Git Patches Flaw That Lets Malicious Repositories Execute Code During Recursive Clones&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://cybersecuritynews.com/git-fixes-security-vulnerabilities/" rel="noopener noreferrer"&gt;Cyber Security News: Git Fixes 6 Security Vulnerabilities&lt;/a&gt; (the headline this article responds to; not otherwise used)&lt;/li&gt;
&lt;li&gt;&lt;a href="https://finance.biggo.com/news/502ac07c-4968-41f3-941a-d935d0c950c8" rel="noopener noreferrer"&gt;BigGo Finance: Git for Windows v2.56.1 (aggregator, used for the CVSS 8.0 rating and the Windows release date)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/git-for-windows/git/releases" rel="noopener noreferrer"&gt;Git for Windows releases&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://dev-talk.com/post/git-security-release-cve-2026-111760" rel="noopener noreferrer"&gt;DEV Talk&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>security</category>
      <category>git</category>
      <category>cve</category>
      <category>submodules</category>
    </item>
    <item>
      <title>Red Hat Quay CVE-2026-123710: Registry Takeover and Fixes</title>
      <dc:creator>devTalk</dc:creator>
      <pubDate>Sun, 15 Nov 2026 12:31:37 +0000</pubDate>
      <link>https://dev.to/devtalk94/red-hat-quay-cve-2026-123710-registry-takeover-and-fixes-2egj</link>
      <guid>https://dev.to/devtalk94/red-hat-quay-cve-2026-123710-registry-takeover-and-fixes-2egj</guid>
      <description>&lt;p&gt;&lt;em&gt;Last updated: 15 November 2026. This is a developing issue; see the&lt;/em&gt;&lt;em&gt;update log&lt;/em&gt;&lt;em&gt;and re-check Red Hat's advisory before acting.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Red Hat Quay, the container registry that many teams run on-premises and on OpenShift, has a critical flaw in the way it manages its own signing keys. CVE-2026-123710 is scored 9.8 (Critical) and, as described by Red Hat, lets a client with no account install its own trusted signing key. After that it can read private images and overwrite tags. If you run Quay, the registry itself is the thing at risk, and so is every system that pulls from it.&lt;/p&gt;

&lt;p&gt;This article explains in plain terms what the bug is, who is affected, what to do first (before and after patching) and how to reduce your exposure to a poisoned image. I could not run Quay itself, so the vulnerability details come from Red Hat and security press coverage, and I say which is which. One of the mitigations, restricting the key endpoint at your reverse proxy, I did test with nginx.&lt;/p&gt;

&lt;h2&gt;
  
  
  The short version
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;What:&lt;/strong&gt; CVE-2026-123710, CWE-1287 (improper validation of the specified type of input), in Quay's service key server. Red Hat's CVSS 3.1 score is 9.8 with the vector &lt;code&gt;AV:N/AC:L/PR:N/UI:N&lt;/code&gt;: network, low complexity, no privileges, no user interaction.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Impact:&lt;/strong&gt; an attacker can install a signing key that Quay trusts, then mint tokens that give read and write access to repositories. That means exposure of private images and any secrets inside them, and the ability to replace images that other systems pull.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Affected:&lt;/strong&gt; Red Hat Quay 3 and 5, including standalone deployments, the Quay Operator on OpenShift and the mirror registry for OpenShift, according to The Hacker News' reading of Red Hat's data.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Exploited in the wild:&lt;/strong&gt; none of the coverage I read says so, and one vendor write-up lists "no public exploit". That can change quickly.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fix:&lt;/strong&gt; upstream fixes were merged on 11 November. Red Hat has published fixed builds for several Quay 3 branches. See the version note below.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How the attack works
&lt;/h2&gt;

&lt;p&gt;Quay signs the tokens that authorize registry access. The signing keys are managed by a service key server, and keys can be rotated through an API. According to The Hacker News, the key server accepts a rotation request if it carries a token signed by a trusted key with the expected audience and issuer. It does not check that the token was issued &lt;em&gt;for key rotation&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;That is the gap:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;An unauthenticated client requests an anonymous registry token from the auth endpoint (&lt;code&gt;/v2/auth&lt;/code&gt;) and chooses the audience.&lt;/li&gt;
&lt;li&gt;That token passes the key server's checks, so the client can ask the key server to add or rotate a key.&lt;/li&gt;
&lt;li&gt;The attacker's key is accepted as trusted. It can be set with no expiry, and it survives restarts.&lt;/li&gt;
&lt;li&gt;With that key the attacker can sign tokens that Quay honors for any repository, and can pull private images or push tampered ones under existing tags.&lt;/li&gt;
&lt;li&gt;Red Hat's report also says the rotation deletes the legitimate instance key as a side effect, and the attacker's key can delete replacement keys. That can break legitimate pushes and pulls.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Two points from Red Hat that change what you might assume:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Turning off anonymous access does not protect you.&lt;/strong&gt; Red Hat says any valid Quay account can still exploit the flaw.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Resetting passwords or regenerating robot tokens does not remove the attacker's key.&lt;/strong&gt; The key lives in Quay's key store, not in a user credential.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  A second flaw in the same fix: CVE-2026-110697
&lt;/h2&gt;

&lt;p&gt;The same researcher, Red Hat's Dave O'Connor, found a related issue, scored 9.9. As The Hacker News describes it, the robot-account listing code builds a SQL &lt;code&gt;LIKE&lt;/code&gt; pattern from the namespace name without escaping wildcards. In SQL &lt;code&gt;LIKE&lt;/code&gt;, an underscore matches any single character, so a crafted namespace can match another tenant's namespace and return its robot accounts with their tokens. The only prerequisite reported is the ability to create a namespace. Stolen robot tokens allow reading, pushing or overwriting another tenant's images.&lt;/p&gt;

&lt;p&gt;This one is easier to understand if you have written SQL: it is the same class of mistake as forgetting that &lt;code&gt;%&lt;/code&gt; and &lt;code&gt;_&lt;/code&gt; are special inside a &lt;code&gt;LIKE&lt;/code&gt;. Escape them, or use an exact match when you mean one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Which versions are fixed?
&lt;/h2&gt;

&lt;p&gt;This is the part to verify with Red Hat directly, because the sources disagree on timing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The Hacker News reports fixed builds for eight Quay 3 branches. It also notes that, when it checked, the CVE entry still showed no fix, and that the second CVE was not listed in the individual advisories.&lt;/li&gt;
&lt;li&gt;A third-party aggregator's summary of Red Hat advisory RHSA-2026:99026 (Red Hat Quay 3.17.7, published 11 November, updated 13 November) lists both CVE-2026-123710 and CVE-2026-110697 among 25 fixed CVEs. I could not open Red Hat's errata page itself, so confirm it on Red Hat's site.&lt;/li&gt;
&lt;li&gt;No fixed Quay 5 build was identified in the sources I read.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In practice: find your Quay version, look up the errata for your branch on the Red Hat Customer Portal, and upgrade to the build that lists CVE-2026-123710. If your branch has no fixed build yet, use the mitigations below and follow Red Hat's solution article referenced in the coverage.&lt;/p&gt;

&lt;h2&gt;
  
  
  What to do first
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Restrict the key endpoint
&lt;/h3&gt;

&lt;p&gt;Red Hat's mitigation is to restrict access to the &lt;code&gt;/keys&lt;/code&gt; endpoint at the proxy or load balancer, so that only trusted internal components can reach it. Here is an nginx example. Adjust the network range to match your internal services:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight nginx"&gt;&lt;code&gt;&lt;span class="n"&gt;location&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;keys&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;allow&lt;/span&gt; &lt;span class="mf"&gt;10.20&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c1"&gt;# internal components that need the key server&lt;/span&gt;
    &lt;span class="n"&gt;deny&lt;/span&gt;  &lt;span class="n"&gt;all&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;proxy_pass&lt;/span&gt; &lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="c1"&gt;//quay_backend;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I tested this pattern with nginx 1.24 in front of a dummy upstream. From a client outside the allowed range, all of these returned &lt;strong&gt;403&lt;/strong&gt;: &lt;code&gt;/keys&lt;/code&gt;, &lt;code&gt;/keys/services/quay/keys/abc&lt;/code&gt;, &lt;code&gt;//keys/x&lt;/code&gt;, &lt;code&gt;/%6beys/x&lt;/code&gt; (URL-encoded) and &lt;code&gt;/keysfoo&lt;/code&gt; (it is a prefix match), and so did a PUT. From an allowed client, the same path reached the upstream and returned 200. Things to note:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;/KEYS&lt;/code&gt; (upper case) was &lt;em&gt;not&lt;/em&gt; blocked; it reached the upstream. nginx matches paths case-sensitively. Whether Quay treats that path as the same endpoint I could not check, so test your own deployment and, if needed, deny at a broader level.&lt;/li&gt;
&lt;li&gt;Replace &lt;code&gt;quay_backend&lt;/code&gt; with your real upstream, and keep your existing proxy settings. This snippet is not a complete Quay configuration.&lt;/li&gt;
&lt;li&gt;If another load balancer sits in front of nginx, the client address nginx sees is that balancer's. Configure real client IP handling, or apply the restriction on the outermost layer.&lt;/li&gt;
&lt;li&gt;One vendor write-up also suggests limiting &lt;code&gt;/v2/auth&lt;/code&gt;. Be careful: ordinary &lt;code&gt;docker login&lt;/code&gt; and pulls go through the auth endpoint, so blocking it for clients will break normal use. Red Hat's stated mitigation names &lt;code&gt;/keys&lt;/code&gt; only.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Check which parts of your own platform (Clair, build workers, operators) talk to the key server before you apply a deny rule, so you do not cut them off.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Look for planted keys
&lt;/h3&gt;

&lt;p&gt;Red Hat's guidance is to review audit logs for &lt;code&gt;service_key_rotate&lt;/code&gt; and &lt;code&gt;service_key_delete&lt;/code&gt; events where the &lt;code&gt;expiration_date&lt;/code&gt; is null, and to remove unrecognized approved keys. Legitimate service keys are normally expected to expire, so a key with no expiry added through the key server deserves attention. I cannot show you the exact query, because it depends on how you export Quay's audit log (the UI, the log database or your log shipper).&lt;/p&gt;

&lt;p&gt;Two cautions from Red Hat's text: deleting a rogue key is not durable until you are on a fixed build, because the attacker can add it again, and compromise of a key means you should treat what that key could access as exposed.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Patch
&lt;/h3&gt;

&lt;p&gt;Upgrade to a fixed build as described above. After the upgrade, repeat the audit-log and key review, since a key planted earlier would survive an upgrade unless you remove it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Assume images may have been touched? Verify them
&lt;/h2&gt;

&lt;p&gt;If your registry was reachable by untrusted clients while vulnerable, you cannot tell from the registry alone that a tag still points to what you built. The defense is not to trust tags at all.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Reference images by digest&lt;/strong&gt; in Kubernetes manifests and deployment files: &lt;code&gt;image: quay.example.com/org/app@sha256:&amp;lt;digest&amp;gt;&lt;/code&gt;. A digest identifies content; if someone overwrites a tag, a deployment pinned by digest still gets the original image or fails to pull.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Record the digest at build time&lt;/strong&gt;, in your CI output, and compare it with what the registry serves now. Tools such as &lt;code&gt;skopeo inspect&lt;/code&gt; or &lt;code&gt;crane digest&lt;/code&gt; can read a digest from a registry. I have not run them against Quay.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Audit recent pushes and tag changes&lt;/strong&gt; for ones you cannot match to a pipeline run.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rotate secrets&lt;/strong&gt; that were baked into images. Private images can contain credentials, and this flaw exposes private images. Rotating the Quay robot tokens alone is not enough, as noted above.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Consider image signing&lt;/strong&gt; (for example Sigstore's cosign) so deployment can verify who built an image. That is a broader project and I did not test it here.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Who should worry most
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Teams running Quay on a network reachable by many users, partners or the internet.&lt;/li&gt;
&lt;li&gt;Multi-tenant installations, because of the second flaw.&lt;/li&gt;
&lt;li&gt;Anyone whose CI/CD pulls base images or deploy images from Quay automatically. A swapped image is a supply chain attack on everything downstream.&lt;/li&gt;
&lt;li&gt;OpenShift users on the integrated registry or the mirror registry, which are listed as affected by The Hacker News.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Red Hat's hosted Quay.io service was listed as already patched for the second CVE at the time of disclosure by one write-up; I found no equivalent statement for the first one, so check Red Hat's notice if you use the hosted service.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common mistakes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Disabling anonymous access and considering the problem solved. Any valid account can still exploit it.&lt;/li&gt;
&lt;li&gt;Rotating user passwords and robot tokens, but leaving a rogue signing key in place.&lt;/li&gt;
&lt;li&gt;Deleting a suspicious key before patching, and not checking that it did not come back.&lt;/li&gt;
&lt;li&gt;Blocking &lt;code&gt;/v2/auth&lt;/code&gt; broadly and breaking normal logins.&lt;/li&gt;
&lt;li&gt;Patching without checking that your branch's errata actually lists the CVE.&lt;/li&gt;
&lt;li&gt;Pulling by mutable tags (&lt;code&gt;:latest&lt;/code&gt;, &lt;code&gt;:prod&lt;/code&gt;) when integrity matters.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Related Dev Talk articles
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dev-talk.com/post/palo-alto-pan-os-cve-2026-0330-panorama-rce" rel="noopener noreferrer"&gt;Palo Alto PAN-OS Root RCE (CVE-2026-0330): Who Is Affected and What to Patch&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev-talk.com/post/chrome-zero-day-cve-2026-125350-update-check" rel="noopener noreferrer"&gt;Chrome Zero-Day CVE-2026-125350: What It Is, Who Is Affected and How to Update&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev-talk.com/post/cursor-claude-code-extension-backdoor-what-to-check" rel="noopener noreferrer"&gt;Malicious Claude Code Extension in the Cursor Marketplace: What Happened and How to Check Your Machine&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Frequently asked questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Is CVE-2026-123710 being exploited?
&lt;/h3&gt;

&lt;p&gt;None of the sources I read says it is. One write-up lists no public exploit. Treat it as exploitable, because the attack needs no authentication and Red Hat has published the details.&lt;/p&gt;

&lt;h3&gt;
  
  
  Does it need an account?
&lt;/h3&gt;

&lt;p&gt;No. Anonymous access, which is enabled by default according to one report, is enough. With anonymous access disabled, any valid account is enough, per Red Hat.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is Quay 5 affected?
&lt;/h3&gt;

&lt;p&gt;The Hacker News reports that Red Hat lists all Quay 3 and Quay 5 versions as affected. I found no fixed Quay 5 build in the sources, so ask Red Hat or check the advisory.&lt;/p&gt;

&lt;h3&gt;
  
  
  Will changing my passwords help?
&lt;/h3&gt;

&lt;p&gt;No. The attacker's signing key is separate from user passwords and robot tokens, and it has to be removed from the key store.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can I just block /keys and skip patching?
&lt;/h3&gt;

&lt;p&gt;Blocking it reduces exposure, and it is Red Hat's recommended mitigation while you patch. It is not a replacement for the fix.&lt;/p&gt;

&lt;h2&gt;
  
  
  update log
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;15 November 2026:&lt;/strong&gt; first version.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;To recheck on each update:&lt;/strong&gt; Red Hat's CVE page and errata for fixed versions per branch, any exploitation reports, a Quay 5 fix, and Red Hat's solution article for key removal.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://access.redhat.com/security/cve/cve-2026-123710" rel="noopener noreferrer"&gt;Red Hat Customer Portal: CVE-2026-123710&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.securityweek.com/critical-red-hat-quay-vulnerability-could-expose-private-container-images/" rel="noopener noreferrer"&gt;SecurityWeek: Critical Red Hat Quay Vulnerability Could Expose Private Container Images&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://thehackernews.com/2026/11/critical-red-hat-quay-flaw-lets.html" rel="noopener noreferrer"&gt;The Hacker News: Critical Red Hat Quay Flaw Lets Attackers Read and Overwrite All Private Container Images&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://gbhackers.com/critical-red-hat-quay-vulnerability/" rel="noopener noreferrer"&gt;GBHackers: Critical Red Hat Quay Vulnerability Allows Hackers to Hijack Private Container Registries&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aviatrix.ai/threat-research-center/critical-red-hat-quay-flaw-cve-2026-123710-cve-2026-110697-container-registry-compromise/" rel="noopener noreferrer"&gt;Aviatrix: Critical Red Hat Quay Flaws (vendor write-up; see caveats in the checks section)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://radar.offseq.com/threat/red-hat-security-advisory-red-hat-quay-3177-4b4c484d51119e46" rel="noopener noreferrer"&gt;OffSeq Threat Radar: Red Hat Security Advisory, Red Hat Quay 3.17.7 (aggregator)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://dev-talk.com/post/red-hat-quay-cve-2026-123710" rel="noopener noreferrer"&gt;DEV Talk&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>security</category>
      <category>redhatquay</category>
      <category>containerregistry</category>
      <category>cve</category>
    </item>
    <item>
      <title>Nginx 502 Bad Gateway with PHP-FPM: Causes and Fixes</title>
      <dc:creator>devTalk</dc:creator>
      <pubDate>Sun, 15 Nov 2026 04:19:38 +0000</pubDate>
      <link>https://dev.to/devtalk94/nginx-502-bad-gateway-with-php-fpm-causes-and-fixes-ei6</link>
      <guid>https://dev.to/devtalk94/nginx-502-bad-gateway-with-php-fpm-causes-and-fixes-ei6</guid>
      <description>&lt;p&gt;A 502 page tells you nothing. It means Nginx asked PHP-FPM for a response and either couldn't reach it or got something it couldn't use. The browser can't tell you which, but the Nginx error log can, in one line. Most 502 problems are solved by reading that line and matching it to a cause, and this article is organized that way.&lt;/p&gt;

&lt;p&gt;Every error message below is real output. I built an Nginx 1.24.0 and PHP-FPM 8.3.6 setup on Ubuntu 24.04, caused each failure on purpose, and copied the log lines. Paths use the Ubuntu defaults (&lt;code&gt;/var/log/nginx/error.log&lt;/code&gt;, &lt;code&gt;/var/log/php8.3-fpm.log&lt;/code&gt;, &lt;code&gt;/run/php/php8.3-fpm.sock&lt;/code&gt;); adjust for your distribution.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step one: read the error log
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo tail -n 20 /var/log/nginx/error.log
sudo tail -n 20 /var/log/php8.3-fpm.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Find the 502 request in the first file. The message after it is your cause:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Nginx error log says&lt;/th&gt;
&lt;th&gt;Likely cause&lt;/th&gt;
&lt;th&gt;Go to&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;connect() to unix:… failed (2: No such file or directory)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;PHP-FPM isn't running, or the socket path is wrong&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;connect() … failed (111: Connection refused)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Nothing is listening there (stopped, crashed, wrong port)&lt;/td&gt;
&lt;td&gt;
1, 3
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;connect() … failed (13: Permission denied)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Nginx can't open the socket&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;recv() failed (104: Connection reset by peer) while reading response header&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The PHP worker died or was killed mid-request&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;connect() … failed (11: Resource temporarily unavailable)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;All workers busy and the queue is full&lt;/td&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;upstream sent too big header while reading response header&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Response headers exceed Nginx's buffer&lt;/td&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  1. PHP-FPM is down, or the socket path is wrong
&lt;/h2&gt;

&lt;p&gt;The most common one. With PHP-FPM stopped cleanly, the socket file is removed and Nginx logs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;connect() to unix:/var/tmp/fpmtest/php.sock failed (2: No such file or directory) while connecting to upstream
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(My test socket lived in &lt;code&gt;/var/tmp/fpmtest&lt;/code&gt;; yours will be under &lt;code&gt;/run/php/&lt;/code&gt;.) The same message appears when PHP-FPM is running but &lt;code&gt;fastcgi_pass&lt;/code&gt; points at a different file. Pointing at a socket that doesn't exist gives exactly the same error:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;connect() to unix:/var/tmp/fpmtest/php8.2-fpm.sock failed (2: No such file or directory) while connecting to upstream
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This often follows a PHP upgrade: the package installs &lt;code&gt;php8.3-fpm&lt;/code&gt; with a new socket name while the Nginx site still references the old one. The stock Ubuntu 24.04 site template even ships a commented example that still says &lt;code&gt;php7.4-fpm.sock&lt;/code&gt;, which is easy to copy by mistake. Check what is actually listening and compare it with your config:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ls /run/php/
ss -xl &lt;span class="o"&gt;|&lt;/span&gt; grep php
grep -R &lt;span class="s2"&gt;"fastcgi_pass"&lt;/span&gt; /etc/nginx/sites-enabled/
grep -n &lt;span class="s2"&gt;"^listen"&lt;/span&gt; /etc/php/8.3/fpm/pool.d/www.conf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ ss -xl | grep php
u_str LISTEN php.sock
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(Trimmed to the useful columns.) The correct Ubuntu pairing is &lt;code&gt;listen = /run/php/php8.3-fpm.sock&lt;/code&gt; in the pool and the same path in the site:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight nginx"&gt;&lt;code&gt;&lt;span class="n"&gt;location&lt;/span&gt; &lt;span class="o"&gt;~&lt;/span&gt; \&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;php&lt;/span&gt;$ &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;include&lt;/span&gt; &lt;span class="n"&gt;snippets&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;fastcgi&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;php&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;conf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;fastcgi_pass&lt;/span&gt; &lt;span class="n"&gt;unix&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;run&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;php&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;php8&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;fpm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sock&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A harder-killed PHP-FPM behaves differently. I used &lt;code&gt;kill -9&lt;/code&gt; on the master process, which doesn't clean up. The socket file stayed on disk, so the message changed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;connect() to unix:/var/tmp/fpmtest/php.sock failed (111: Connection refused) while connecting to upstream
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A socket file that exists but refuses connections means nobody is behind it. Start the service (&lt;code&gt;sudo systemctl restart php8.3-fpm&lt;/code&gt;), then look at &lt;code&gt;/var/log/php8.3-fpm.log&lt;/code&gt; to see why it stopped.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Permission denied on the socket
&lt;/h2&gt;

&lt;p&gt;PHP-FPM creates the socket with the owner, group and mode from the pool. The PHP manual notes that on Linux, read and write permission on the socket is required for the web server to connect, and that the mode defaults to 0660 with the owner and group set to the user running the pool. If the Nginx worker user isn't that owner or in that group, it can't connect. I broke it deliberately with &lt;code&gt;listen.owner = root&lt;/code&gt;, &lt;code&gt;listen.group = root&lt;/code&gt; and &lt;code&gt;listen.mode = 0600&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;connect() to unix:/var/tmp/fpmtest/php.sock failed (13: Permission denied) while connecting to upstream

$ ls -l /var/tmp/fpmtest/php.sock
srw------- root root
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The fix is to make the pool's socket settings match the user from the &lt;code&gt;user&lt;/code&gt; directive in &lt;code&gt;nginx.conf&lt;/code&gt; (&lt;code&gt;www-data&lt;/code&gt; on Ubuntu):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ini"&gt;&lt;code&gt;&lt;span class="c1"&gt;; /etc/php/8.3/fpm/pool.d/www.conf
&lt;/span&gt;&lt;span class="na"&gt;listen.owner&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;www&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;
&lt;span class="na"&gt;listen.group&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;www&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;
&lt;span class="na"&gt;listen.mode&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0660&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ ls -l /var/tmp/fpmtest/php.sock
srw-rw---- www-data www-data
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Restart PHP-FPM afterward. The socket is created at startup, so a reload of Nginx alone changes nothing. Also check the directory: Nginx must be able to traverse every directory in the socket's path.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. A TCP port mismatch
&lt;/h2&gt;

&lt;p&gt;If you use TCP instead of a socket, both sides must agree on the address. With Nginx pointing at &lt;code&gt;127.0.0.1:9001&lt;/code&gt; and nothing listening there:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;connect() failed (111: Connection refused) while connecting to upstream
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Compare &lt;code&gt;fastcgi_pass 127.0.0.1:9000;&lt;/code&gt; with the pool's &lt;code&gt;listen =&lt;/code&gt; line. The PHP manual warns that an exposed FastCGI port allows arbitrary code execution, so keep TCP bound to &lt;code&gt;127.0.0.1&lt;/code&gt; and list allowed clients if you must listen on a network address. On a single host, a Unix socket is the safer choice.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. The PHP worker dies mid-request
&lt;/h2&gt;

&lt;p&gt;This one is different: the connection succeeds, then the worker disappears before it replies. To reproduce it I had a script kill its own process with signal 11 (segmentation fault):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Nginx: recv() failed (104: Connection reset by peer) while reading response header from upstream
PHP-FPM: WARNING: [pool www] child 2585 exited on signal 11 (SIGSEGV) after 1.222179 seconds from start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The two logs together are the diagnosis: Nginx says the connection was reset, PHP-FPM says which worker died and from which signal. A real segfault usually comes from a PHP extension or a bug in a PHP build, so look at what changed recently. Signal 9 (SIGKILL) is different. I did not test it, but in practice it often means the kernel's out-of-memory killer, so check &lt;code&gt;dmesg&lt;/code&gt; or &lt;code&gt;journalctl -k&lt;/code&gt; for "Out of memory" around the same timestamp.&lt;/p&gt;

&lt;h3&gt;
  
  
  Slow script killed by request_terminate_timeout: a 502, not a 504
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;request_terminate_timeout&lt;/code&gt; (default 0, meaning off) kills a worker that's been serving one request too long. With it set to &lt;code&gt;2s&lt;/code&gt; and a script that sleeps six seconds, the browser sees a 502, not a timeout error:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Nginx: recv() failed (104: Connection reset by peer) while reading response header from upstream
PHP-FPM: WARNING: [pool www] child 2611, script '/var/tmp/fpmtest/www/slow.php' (request: "GET /slow.php?s=6") execution timed out (2.114876 sec), terminating
PHP-FPM: WARNING: [pool www] child 2611 exited on signal 15 (SIGTERM) after 3.336074 seconds from start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The PHP-FPM log names the script and request, so you know exactly what to fix. Compare that with the case where Nginx gives up first, with &lt;code&gt;fastcgi_read_timeout 2s;&lt;/code&gt; and no FPM limit:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HTTP 504
upstream timed out (110: Connection timed out) while reading response header from upstream
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A rule of thumb from these two results: &lt;strong&gt;504 means Nginx stopped waiting, 502 with "Connection reset" means PHP-FPM ended the request or died.&lt;/strong&gt; Nginx's &lt;code&gt;fastcgi_read_timeout&lt;/code&gt; defaults to 60 seconds and applies between two successive reads, not to the whole response. Raising timeouts only hides a slow request; find out why it's slow first. For long exports and reports, queue the work instead.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. All workers are busy
&lt;/h2&gt;

&lt;p&gt;PHP-FPM can only serve &lt;code&gt;pm.max_children&lt;/code&gt; requests at once. Ubuntu's default pool uses &lt;code&gt;pm = dynamic&lt;/code&gt; and &lt;code&gt;pm.max_children = 5&lt;/code&gt;, which is small for a busy site. I limited the pool to one worker and sent three slow requests at once. By default, extra requests wait in the socket's backlog (the PHP manual gives 511 as the Linux default), so they don't fail at once. They time out:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;slow.php?s=5 -&amp;gt; HTTP 504
slow.php?s=5 -&amp;gt; HTTP 504
slow.php?s=5 -&amp;gt; HTTP 504

Nginx: upstream timed out (110: Connection timed out) while reading response header from upstream
PHP-FPM: WARNING: [pool www] server reached pm.max_children setting (1), consider raising it
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The PHP-FPM warning is the confirmation. In my test the symptom was a 504. A 502 appears when the queue itself is full. I set &lt;code&gt;listen.backlog = 1&lt;/code&gt; to make that easy to see, with five simultaneous requests to a one-worker pool:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;connect() to unix:/var/tmp/fpmtest/php.sock failed (11: Resource temporarily unavailable) while connecting to upstream
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In that run two requests got a 502 with that message, two succeeded, and one timed out, so you may see a mix. On a real server the default backlog is large, so you'll normally meet the 504 form first. The fix is the same: serve requests faster, or allow more workers. For memory-based sizing, measure what one worker actually uses under your real application, not an idle one:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ps --no-headers -o rss,cmd -C php-fpm8.3 &lt;span class="o"&gt;|&lt;/span&gt; grep pool \
  &lt;span class="o"&gt;|&lt;/span&gt; awk &lt;span class="s1"&gt;'{s+=$1; n++} END {printf "%d workers, average %.0f MB each\n", n, s/n/1024}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;3 workers, average 13 MB each
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That 13 MB is for a bare test script; a framework application will be much larger, and the number only means something measured on your own app under load. A common rule of thumb is to divide the memory you can spare for PHP by the average worker size and keep a margin, then set &lt;code&gt;pm.max_children&lt;/code&gt; below that. Don't raise it past what the database can handle either, since more workers means more connections.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. The response header is too big
&lt;/h2&gt;

&lt;p&gt;Nginx reads the start of the FastCGI response, the headers, into one buffer (&lt;code&gt;fastcgi_buffer_size&lt;/code&gt;, 4k or 8k by default according to the Nginx docs). Large cookies, long redirect URLs, or many &lt;code&gt;Set-Cookie&lt;/code&gt; headers can overflow it. A script that sends a 9,000-byte header reproduces it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;upstream sent too big header while reading response header from upstream
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The obvious fix doesn't work on its own. I set only &lt;code&gt;fastcgi_buffer_size 16k;&lt;/code&gt; and Nginx refused to start:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[emerg] "fastcgi_busy_buffers_size" must be less than the size of all "fastcgi_buffers" minus one buffer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Nginx docs say the default &lt;code&gt;fastcgi_busy_buffers_size&lt;/code&gt; is the size of two buffers, so it grows with the header buffer. With a 16k header buffer and the default eight 4k response buffers, it no longer fits, so the response buffers have to grow too. This worked:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight nginx"&gt;&lt;code&gt;&lt;span class="n"&gt;fastcgi_buffer_size&lt;/span&gt; &lt;span class="mi"&gt;16k&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;fastcgi_buffers&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt; &lt;span class="mi"&gt;16k&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The request returned 200. This is also why you should always run &lt;code&gt;sudo nginx -t&lt;/code&gt; before reloading; the error above would have taken the site down on a restart. If your headers are huge because of cookies, consider whether the application is storing too much in them.&lt;/p&gt;

&lt;h2&gt;
  
  
  A five-command checklist
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo tail -n 20 /var/log/nginx/error.log      &lt;span class="c"&gt;# what Nginx saw&lt;/span&gt;
sudo tail -n 20 /var/log/php8.3-fpm.log       &lt;span class="c"&gt;# what PHP-FPM saw&lt;/span&gt;
ss -xl &lt;span class="o"&gt;|&lt;/span&gt; grep php                              &lt;span class="c"&gt;# is a socket listening?&lt;/span&gt;
sudo nginx -t                                  &lt;span class="c"&gt;# is the Nginx config valid?&lt;/span&gt;
sudo php-fpm8.3 -t                             &lt;span class="c"&gt;# is the pool config valid?&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ nginx -t -c nginx.conf
nginx: the configuration file nginx.conf syntax is ok
nginx: configuration file nginx.conf test is successful
$ php-fpm8.3 -t -y php-fpm.conf
NOTICE: configuration file php-fpm.conf test is successful
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(My test used custom config paths, hence the &lt;code&gt;-c&lt;/code&gt; and &lt;code&gt;-y&lt;/code&gt; options; on a normal install just run the commands as in the list above.)&lt;/p&gt;

&lt;h2&gt;
  
  
  Common mistakes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Restarting Nginx when PHP-FPM is the problem.&lt;/strong&gt; Nginx is rarely the broken part; read both logs first.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Raising&lt;/strong&gt;&lt;code&gt;fastcgi_read_timeout&lt;/code&gt;&lt;strong&gt;to "fix" a 504.&lt;/strong&gt; It only hides the slow request.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Changing socket permissions but only reloading Nginx.&lt;/strong&gt; The socket belongs to PHP-FPM; restart that.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Forgetting the socket name after a PHP upgrade.&lt;/strong&gt; It includes the version.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Setting&lt;/strong&gt;&lt;code&gt;pm.max_children&lt;/code&gt;&lt;strong&gt;from guesswork.&lt;/strong&gt; Measure real worker memory and respect the database limits.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Skipping&lt;/strong&gt;&lt;code&gt;nginx -t&lt;/code&gt;&lt;strong&gt;.&lt;/strong&gt; One bad directive can stop the whole server on restart.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Alternatives
&lt;/h2&gt;

&lt;p&gt;Unix socket versus TCP is a trade-off, not a rule. A socket avoids a network port and is controlled by file permissions, which is why the PHP manual prefers it when the web server is on the same host. TCP is needed when PHP-FPM runs in a separate container or machine. This article's examples use Nginx only; I did not test Apache with PHP-FPM.&lt;/p&gt;

&lt;h2&gt;
  
  
  Related Dev Talk articles
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dev-talk.com/post/laravel-scheduler-not-running-cron-fixes" rel="noopener noreferrer"&gt;Laravel Scheduler Not Running: Cron and schedule:run Fixes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev-talk.com/post/laravel-env-configuration-env-vs-config" rel="noopener noreferrer"&gt;Laravel .env Configuration: env() vs config() Explained&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev-talk.com/post/detect-fix-memory-leaks-php-applications" rel="noopener noreferrer"&gt;How to Detect and Fix Memory Leaks in PHP Applications&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Frequently asked questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is the difference between 502, 503 and 504?
&lt;/h3&gt;

&lt;p&gt;In this setup, 502 means Nginx couldn't get a valid response from PHP-FPM, 504 means it waited too long (the timeout cases above), and a 500 usually comes from the application itself, such as an uncaught PHP error. I haven't covered 503 here.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is a 502 always a PHP-FPM problem?
&lt;/h3&gt;

&lt;p&gt;With &lt;code&gt;fastcgi_pass&lt;/code&gt;, the upstream is PHP-FPM, so yes in practice, though the cause can be Nginx's own configuration, such as a wrong socket path or buffer size. If you proxy to another app server, the same log-reading approach applies but the messages name that server.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why does it only happen under load?
&lt;/h3&gt;

&lt;p&gt;Usually worker exhaustion (cause 5): too few workers, or slow requests holding them. Look for the "reached pm.max_children" warning and check what the slow requests are doing.&lt;/p&gt;

&lt;h3&gt;
  
  
  Should I use a socket or TCP?
&lt;/h3&gt;

&lt;p&gt;A socket on a single host; TCP when PHP-FPM is elsewhere. Make sure Nginx and PHP-FPM agree, and restrict TCP to localhost or trusted addresses.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.php.net/manual/en/install.fpm.configuration.php" rel="noopener noreferrer"&gt;PHP Manual: FastCGI Process Manager (FPM) configuration&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://freenginx.org/en/docs/http/ngx_http_fastcgi_module.html" rel="noopener noreferrer"&gt;Module ngx_http_fastcgi_module (documentation copy)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://dev-talk.com/post/nginx-502-bad-gateway-php-fpm-causes-fixes" rel="noopener noreferrer"&gt;DEV Talk&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>nginx</category>
      <category>phpfpm</category>
      <category>502badgateway</category>
      <category>troubleshooting</category>
    </item>
    <item>
      <title>Laravel Scheduler Not Running: Cron and schedule:run Fixes</title>
      <dc:creator>devTalk</dc:creator>
      <pubDate>Sun, 15 Nov 2026 03:06:53 +0000</pubDate>
      <link>https://dev.to/devtalk94/laravel-scheduler-not-running-cron-and-schedulerun-fixes-3o2k</link>
      <guid>https://dev.to/devtalk94/laravel-scheduler-not-running-cron-and-schedulerun-fixes-3o2k</guid>
      <description>&lt;p&gt;You defined a scheduled task, deployed, and nothing happens. No error, no log line, no email. The scheduler is one of the most frustrating parts of Laravel to debug because it has two separate layers that can fail silently: &lt;strong&gt;cron&lt;/strong&gt; has to start Laravel every minute, and &lt;strong&gt;Laravel&lt;/strong&gt; then decides which tasks are due. Fixing it is mostly a matter of finding out which layer is broken, and that takes three commands.&lt;/p&gt;

&lt;p&gt;Everything below was run on Laravel 13.40.0 and PHP 8.3 with a real &lt;code&gt;cron&lt;/code&gt; daemon on Debian, not just simulated.&lt;/p&gt;

&lt;h2&gt;
  
  
  How the scheduler works
&lt;/h2&gt;

&lt;p&gt;Laravel doesn't run its own background process. You add a single cron entry that calls &lt;code&gt;php artisan schedule:run&lt;/code&gt; every minute, and Laravel checks which of your tasks are due at that moment. Tasks are defined in &lt;code&gt;routes/console.php&lt;/code&gt; (Laravel's docs also allow &lt;code&gt;withSchedule&lt;/code&gt; in &lt;code&gt;bootstrap/app.php&lt;/code&gt;). The entry from the official docs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;* * * * * &lt;span class="nb"&gt;cd&lt;/span&gt; /path-to-your-project &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; php artisan schedule:run &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; /dev/null 2&lt;span class="o"&gt;&amp;gt;&amp;amp;&lt;/span&gt;1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The test app for this article has two every-minute tasks and one daily task:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// routes/console.php&lt;/span&gt;
&lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;Illuminate&lt;/span&gt;\&lt;span class="nc"&gt;Support&lt;/span&gt;\&lt;span class="nc"&gt;Facades&lt;/span&gt;\&lt;span class="nc"&gt;Schedule&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nc"&gt;Schedule&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;file_put_contents&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;storage_path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'logs/heartbeat.log'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'H:i:s'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="s2"&gt;" heartbeat\n"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;FILE_APPEND&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;everyMinute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;name&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'heartbeat'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nc"&gt;Schedule&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;everyMinute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;name&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'slow-report'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;withoutOverlapping&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nc"&gt;Schedule&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;dailyAt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'09:00'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;timezone&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Asia/Colombo'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;name&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'morning-digest'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 1: Does Laravel see your tasks?
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ php artisan schedule:list

  *  * * * *  heartbeat ........................ Next Due: 46 seconds from now
  *  * * * *  slow-report ...................... Next Due: 46 seconds from now
  30 3 * * *  morning-digest ..................... Next Due: 12 hours from now
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If your task is missing here, the problem is in the code: the schedule is defined in the wrong file, the file has an error, or the config cache is stale (&lt;code&gt;php artisan config:clear&lt;/code&gt;). Cron is not involved yet. Note that &lt;code&gt;schedule:list&lt;/code&gt; only tells you what is &lt;em&gt;next&lt;/em&gt; due; it doesn't tell you what already ran.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Does it run when you start it by hand?
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ php artisan schedule:run

  2026-11-10 14:41:07 Running [heartbeat] ........................ 0.21ms DONE
  2026-11-10 14:41:07 Running [slow-report] ......................... 25s DONE
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the key split. If it works by hand but not on its own, the problem is cron (or how cron starts PHP). If it doesn't work by hand either, the problem is on the Laravel side, and the causes further down apply.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Is cron actually firing it?
&lt;/h2&gt;

&lt;p&gt;First check that the entry exists for the right user with &lt;code&gt;crontab -l&lt;/code&gt;. Then make cron prove it's running. The cleanest test is to have one task that leaves a trace, like the heartbeat above. With a correct entry installed, the log fills up on its own:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ crontab -l
* * * * * cd /var/www/app &amp;amp;&amp;amp; php artisan schedule:run &amp;gt;&amp;gt; /dev/null 2&amp;gt;&amp;amp;1

$ cat storage/logs/heartbeat.log
14:43:01 heartbeat
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(In my run the path was a scratch directory; I show &lt;code&gt;/var/www/app&lt;/code&gt; here.) If the entry exists and the heartbeat never appears, work through the cron-side causes next.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cron-side causes
&lt;/h2&gt;

&lt;h3&gt;
  
  
  A wrong path, hidden by &amp;gt; /dev/null
&lt;/h3&gt;

&lt;p&gt;The official one-liner throws away all output, so a wrong &lt;code&gt;cd&lt;/code&gt; path fails without a trace. Switching the redirect to a log file looks like the fix, but there is a trap. I installed two lines with a bad path:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;* * * * * cd /wrong/path &amp;amp;&amp;amp; php artisan schedule:run &amp;gt;&amp;gt; /tmp/sched-cron-bad.log 2&amp;gt;&amp;amp;1
* * * * * (cd /wrong/path &amp;amp;&amp;amp; php artisan schedule:run) &amp;gt;&amp;gt; /tmp/sched-cron.log 2&amp;gt;&amp;amp;1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ cat /tmp/sched-cron-bad.log
cat: /tmp/sched-cron-bad.log: No such file or directory
$ cat /tmp/sched-cron.log
/bin/sh: 1: cd: can't cd to /wrong/path
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the first line the redirect belongs only to the &lt;code&gt;php&lt;/code&gt; command, which never ran, so the &lt;code&gt;cd&lt;/code&gt; error went to cron's own error channel (cron normally tries to mail it to the user, which is rarely read) and the log file was never created. Wrapping both commands in parentheses sends everything to the log. This is my recommended form:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;* * * * * &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; /var/www/app &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; /usr/bin/php artisan schedule:run&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; /var/log/laravel-scheduler.log 2&lt;span class="o"&gt;&amp;gt;&amp;amp;&lt;/span&gt;1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note that &lt;code&gt;schedule:run&lt;/code&gt; prints a line every minute, even when nothing is due, so that log grows; rotate it, or point it at a path you clean up.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cron's minimal PATH
&lt;/h3&gt;

&lt;p&gt;Cron does not load your shell profile. I had cron write out its own environment next to my interactive one:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ cat /tmp/cronpath.txt
PATH=/usr/bin:/bin
php: /usr/bin/php
composer:

$ echo $PATH      # my interactive shell
/home/claude/.npm-global/bin:...:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(The interactive PATH is shortened.) Cron's PATH was just &lt;code&gt;/usr/bin:/bin&lt;/code&gt;, so &lt;code&gt;php&lt;/code&gt; was found in &lt;code&gt;/usr/bin&lt;/code&gt; but &lt;code&gt;composer&lt;/code&gt;, installed in &lt;code&gt;/usr/local/bin&lt;/code&gt;, was not. If PHP lives somewhere unusual on your server (a versioned directory, a control-panel install, a Homebrew path), a bare &lt;code&gt;php&lt;/code&gt; in the crontab will fail with "not found". Use the absolute path from &lt;code&gt;command -v php&lt;/code&gt;. This was tested with Debian's cron; other cron implementations and distributions may set a different default PATH, so print it on your server the same way.&lt;/p&gt;

&lt;h3&gt;
  
  
  Wrong user
&lt;/h3&gt;

&lt;p&gt;Each user has a separate crontab. If the entry is in root's crontab but your files belong to the web user, log and cache files created by the scheduler can end up owned by root and later break web requests. I did not test this, but the safe habit is to install the entry for the same user that runs your application (&lt;code&gt;crontab -u www-data -e&lt;/code&gt; on many Debian-based systems).&lt;/p&gt;

&lt;h2&gt;
  
  
  Laravel-side causes
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The app is in maintenance mode
&lt;/h3&gt;

&lt;p&gt;The docs say scheduled tasks don't run while the application is in maintenance mode. What the command prints is the confusing part:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ php artisan down
$ php artisan schedule:run

   INFO  No scheduled commands are ready to run.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That message makes it look like nothing is due, when in fact everything is being skipped. If your deploy script runs &lt;code&gt;php artisan down&lt;/code&gt; and a step fails before &lt;code&gt;php artisan up&lt;/code&gt;, your scheduler stays dead until someone notices. Tasks that must run during maintenance can opt in with &lt;code&gt;evenInMaintenanceMode()&lt;/code&gt;, per the docs.&lt;/p&gt;

&lt;h3&gt;
  
  
  A stuck withoutOverlapping lock
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;withoutOverlapping()&lt;/code&gt; stops a task from starting while the previous run is still going. That's exactly what happened when I started a second &lt;code&gt;schedule:run&lt;/code&gt; while &lt;code&gt;slow-report&lt;/code&gt; was running: it ran &lt;code&gt;heartbeat&lt;/code&gt; and skipped the slow task, without printing anything about the skip.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ php artisan schedule:run      # while slow-report is still running

  2026-11-10 14:41:35 Running [heartbeat] ........................ 0.19ms DONE
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The lock is held in your cache. If the process is killed mid-task (a deploy restart, an out-of-memory kill, a &lt;code&gt;kill -9&lt;/code&gt;), the lock is not released. I killed a run halfway through the slow task and ran the scheduler again:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ php artisan schedule:run      # after the crash

  2026-11-10 14:42:03 Running [heartbeat] ........................ 0.26ms DONE
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With the database cache driver I looked at the lock row directly, and it was still there after the crash:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;laravel-cache-framework/schedule-0b137ec5...1314 expires in 24 hours
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The slow task is skipped, silently, until the lock expires. The docs give the default expiry as 24 hours, and the row above agrees, so a crashed run can silence a task for a day. You can pass a shorter lifetime in minutes, &lt;code&gt;withoutOverlapping(10)&lt;/code&gt;, and you can clear stuck locks:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ php artisan schedule:clear-cache
$ php artisan schedule:run

  2026-11-10 14:42:03 Running [heartbeat] ........................ 0.21ms DONE
  2026-11-10 14:42:03 Running [slow-report] ......................... 25s DONE
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(The command also printed an &lt;code&gt;INFO Deleting mutex for []&lt;/code&gt; line, which I trimmed. The task ran again afterwards, which is what matters.) Choose the expiry to be a little longer than the longest legitimate run of the task, not 24 hours.&lt;/p&gt;

&lt;h3&gt;
  
  
  Timezone surprises
&lt;/h3&gt;

&lt;p&gt;Tasks run on the server's schedule clock, which comes from your app configuration, unless you set a timezone on the task. In the test app, &lt;code&gt;dailyAt('09:00')-&amp;gt;timezone('Asia/Colombo')&lt;/code&gt; showed up in &lt;code&gt;schedule:list&lt;/code&gt; as &lt;code&gt;30 3 * * *&lt;/code&gt;, which is 03:30 UTC, the same instant as 09:00 in Colombo (UTC+5:30). If a daily task fires at an hour you don't expect, check &lt;code&gt;schedule:list&lt;/code&gt; against the timezone you meant. The docs also warn that around daylight saving changes a task may run twice or not at all, and recommend avoiding timezone scheduling where you can.&lt;/p&gt;

&lt;h3&gt;
  
  
  onOneServer and the cache driver
&lt;/h3&gt;

&lt;p&gt;If you run the scheduler on several servers and use &lt;code&gt;onOneServer()&lt;/code&gt;, the docs require the default cache driver to be &lt;code&gt;database&lt;/code&gt;, &lt;code&gt;memcached&lt;/code&gt;, &lt;code&gt;dynamodb&lt;/code&gt; or &lt;code&gt;redis&lt;/code&gt;, with every server talking to the same central cache. With the &lt;code&gt;file&lt;/code&gt; or &lt;code&gt;array&lt;/code&gt; driver each server has its own locks, which defeats the purpose. I did not test a multi-server setup.&lt;/p&gt;

&lt;h2&gt;
  
  
  Local development: skip cron
&lt;/h2&gt;

&lt;p&gt;On your own machine you don't need a cron entry. &lt;code&gt;schedule:work&lt;/code&gt; runs in the foreground and invokes the scheduler every minute until you stop it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ php artisan schedule:work

   INFO  Running scheduled tasks.

  2026-11-10 14:48:00 Running [heartbeat] ........................ 0.25ms DONE
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(I stopped it after 80 seconds and removed the &lt;code&gt;slow-report&lt;/code&gt; lines. Each minute it adds another batch of lines at the top of the minute.) It's a convenient test, but it doesn't replace cron on a server, since it stops when the terminal or process does.&lt;/p&gt;

&lt;h2&gt;
  
  
  Know when it stops working
&lt;/h2&gt;

&lt;p&gt;The default setup tells you nothing when the scheduler dies. The docs describe &lt;code&gt;appendOutputTo()&lt;/code&gt; for command output, &lt;code&gt;onFailure()&lt;/code&gt; callbacks for tasks that exit non-zero, and ping methods for monitoring services. The simplest useful addition is a dead-man's switch: a task that pings a monitoring URL every minute (or a heartbeat file like the one above) and an alert when it goes quiet. Without something like that, a stuck lock or a failed deploy can silence your scheduled tasks for days.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common mistakes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Adding one cron entry per task.&lt;/strong&gt; You need a single entry that runs &lt;code&gt;schedule:run&lt;/code&gt; every minute; Laravel does the rest.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Using&lt;/strong&gt;&lt;code&gt;&amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;/code&gt;&lt;strong&gt;while debugging.&lt;/strong&gt; It hides the exact error you need. Log to a file until it works.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Relying on a bare&lt;/strong&gt;&lt;code&gt;php&lt;/code&gt;&lt;strong&gt;in the crontab.&lt;/strong&gt; Cron's PATH is minimal; use the full path.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Leaving the app in maintenance mode after a failed deploy.&lt;/strong&gt; The scheduler stops without a clear message.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Assuming a task that does not run has failed.&lt;/strong&gt; A held &lt;code&gt;withoutOverlapping&lt;/code&gt; lock skips it silently.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Expecting&lt;/strong&gt;&lt;code&gt;schedule:list&lt;/code&gt;&lt;strong&gt;to show run history.&lt;/strong&gt; It only shows what is due next.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Alternatives
&lt;/h2&gt;

&lt;p&gt;On Linux, a systemd timer can replace cron for the one-minute trigger; the Laravel side (&lt;code&gt;schedule:run&lt;/code&gt;) stays the same. I haven't tested that setup here. If the scheduler is just dispatching queue jobs, also check the worker side: see &lt;a href="https://dev-talk.com/laravel-queue-jobs-not-processing" rel="noopener noreferrer"&gt;Laravel queue jobs not processing&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Related Dev Talk articles
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dev-talk.com/post/laravel-queue-jobs-not-processing" rel="noopener noreferrer"&gt;Laravel queue jobs not processing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev-talk.com/post/laravel-queues-redis-vs-database-driver" rel="noopener noreferrer"&gt;Laravel queues: Redis vs database driver&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev-talk.com/post/laravel-env-configuration-env-vs-config" rel="noopener noreferrer"&gt;Laravel .env configuration: env() vs config()&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Frequently asked questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Do I need a cron entry for every scheduled task?
&lt;/h3&gt;

&lt;p&gt;No. One entry running &lt;code&gt;schedule:run&lt;/code&gt; every minute is enough. Laravel decides which tasks are due.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can the scheduler run more often than once a minute?
&lt;/h3&gt;

&lt;p&gt;Cron itself runs at most once per minute, as the docs note. Laravel supports sub-minute tasks (for example &lt;code&gt;everyTenSeconds()&lt;/code&gt;), in which case &lt;code&gt;schedule:run&lt;/code&gt; keeps running until the end of the current minute. The docs recommend dispatching queued jobs or background commands for that work.&lt;/p&gt;

&lt;h3&gt;
  
  
  Do I need to restart anything after changing the schedule?
&lt;/h3&gt;

&lt;p&gt;Cron starts a fresh PHP process each minute, so new code is picked up on the next run. For long-running sub-minute runs, the docs suggest calling &lt;code&gt;schedule:interrupt&lt;/code&gt; in your deployment script. I did not test that command.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do I check that the scheduler is really running?
&lt;/h3&gt;

&lt;p&gt;Add a tiny task that writes to a file or pings a monitoring URL every minute, as in the heartbeat example.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://laravel.com/framework/docs/scheduling" rel="noopener noreferrer"&gt;Laravel documentation: Task Scheduling&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://dev-talk.com/post/laravel-scheduler-not-running-cron-fixes" rel="noopener noreferrer"&gt;DEV Talk&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>scheduler</category>
      <category>cron</category>
      <category>schedulerun</category>
    </item>
    <item>
      <title>Laravel .env Configuration: env() vs config() Explained</title>
      <dc:creator>devTalk</dc:creator>
      <pubDate>Sat, 14 Nov 2026 15:12:18 +0000</pubDate>
      <link>https://dev.to/devtalk94/laravel-env-configuration-env-vs-config-explained-427h</link>
      <guid>https://dev.to/devtalk94/laravel-env-configuration-env-vs-config-explained-427h</guid>
      <description>&lt;p&gt;&lt;em&gt;Last updated: 9 November 2026. See the&lt;/em&gt;&lt;em&gt;update log&lt;/em&gt;&lt;em&gt;at the end.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The classic Laravel deployment bug goes like this: everything works on your machine, you run &lt;code&gt;php artisan config:cache&lt;/code&gt; in production, and a setting that was fine yesterday is suddenly &lt;code&gt;null&lt;/code&gt;. The cause is almost always an &lt;code&gt;env()&lt;/code&gt; call in the wrong place. This article explains how &lt;code&gt;.env&lt;/code&gt;, &lt;code&gt;env()&lt;/code&gt; and &lt;code&gt;config()&lt;/code&gt; fit together, with short examples you can run, and covers the parts that bite in practice: value types, quoting, environment files, config caching and encrypted env files.&lt;/p&gt;

&lt;p&gt;Everything below was run on Laravel 13.40.0 with PHP 8.3.&lt;/p&gt;

&lt;h2&gt;
  
  
  The flow in one line
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;.env&lt;/code&gt; (or a real environment variable) → read by &lt;code&gt;env()&lt;/code&gt; &lt;strong&gt;inside a file in&lt;/strong&gt;&lt;code&gt;config/&lt;/code&gt; → read everywhere else with &lt;code&gt;config()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The Laravel docs state the rule directly: once the configuration is cached, the &lt;code&gt;.env&lt;/code&gt; file is no longer loaded, so you should only call &lt;code&gt;env()&lt;/code&gt; from your configuration files. Everything else in the app reads &lt;code&gt;config()&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  A working example: adding your own setting
&lt;/h2&gt;

&lt;p&gt;Say you integrate a payment API. First add the values to &lt;code&gt;.env&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;PAYMENT_API_URL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;https://api.pay.example.test
&lt;span class="nv"&gt;PAYMENT_TIMEOUT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;30
&lt;span class="nv"&gt;PAYMENT_DEBUG&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then expose them through a config file. Here I added an entry to &lt;code&gt;config/services.php&lt;/code&gt;. The second argument to &lt;code&gt;env()&lt;/code&gt; is the default, used when the variable doesn't exist:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// config/services.php&lt;/span&gt;
&lt;span class="s1"&gt;'payment'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="s1"&gt;'url'&lt;/span&gt;     &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;env&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'PAYMENT_API_URL'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'https://sandbox.pay.example.test'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s1"&gt;'timeout'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nf"&gt;env&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'PAYMENT_TIMEOUT'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s1"&gt;'debug'&lt;/span&gt;   &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;env&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'PAYMENT_DEBUG'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In application code, use &lt;code&gt;config()&lt;/code&gt; with dot notation. Using the same pattern in a controller, job or service:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$url&lt;/span&gt;     &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;config&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'services.payment.url'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;$timeout&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;config&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'services.payment.timeout'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To see the effect, I printed both calls from an Artisan command. With nothing in &lt;code&gt;.env&lt;/code&gt;, the defaults apply. After adding the three lines, the values come through, already converted: the timeout is an integer, and &lt;code&gt;true&lt;/code&gt; became a real boolean.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-- nothing in .env --
env(PAYMENT_API_URL)             = NULL
config(services.payment.url)     = 'https://sandbox.pay.example.test'
config(services.payment.timeout) = 10
config(services.payment.debug)   = false

-- after adding the three lines --
env(PAYMENT_API_URL)             = 'https://api.pay.example.test'
config(services.payment.url)     = 'https://api.pay.example.test'
config(services.payment.timeout) = 30
config(services.payment.debug)   = true
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(&lt;code&gt;php artisan probe&lt;/code&gt; in these outputs is a throwaway command I defined in &lt;code&gt;routes/console.php&lt;/code&gt; to print the values; it is not built into Laravel.)&lt;/p&gt;

&lt;h2&gt;
  
  
  Real environment variables beat .env
&lt;/h2&gt;

&lt;p&gt;A variable set in the process environment (by your shell, systemd, Docker, your host's dashboard) overrides the same key in &lt;code&gt;.env&lt;/code&gt;. This is what the docs describe, and it is why production servers often need no &lt;code&gt;.env&lt;/code&gt; file at all:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ PAYMENT_API_URL=https://override.example.test php artisan probe
env(PAYMENT_API_URL)         = 'https://override.example.test'
config(services.payment.url) = 'https://override.example.test'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Value types: what env() returns
&lt;/h2&gt;

&lt;p&gt;Everything in &lt;code&gt;.env&lt;/code&gt; is a string, except a few reserved words that &lt;code&gt;env()&lt;/code&gt; converts:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;
&lt;code&gt;.env&lt;/code&gt; value&lt;/th&gt;
&lt;th&gt;
&lt;code&gt;env()&lt;/code&gt; returns&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;true&lt;/code&gt; / &lt;code&gt;(true)&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;true&lt;/code&gt; (bool)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;false&lt;/code&gt; / &lt;code&gt;(false)&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;false&lt;/code&gt; (bool)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;empty&lt;/code&gt; / &lt;code&gt;(empty)&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;''&lt;/code&gt; (empty string)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;null&lt;/code&gt; / &lt;code&gt;(null)&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;&lt;code&gt;null&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;I tested a few of these, including one the docs don't spell out, a quoted &lt;code&gt;"false"&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.env:  FLAG_TRUE=true  FLAG_FALSE=false  FLAG_QUOTED_FALSE="false"
       FLAG_EMPTY=     FLAG_NULL=null    FLAG_TEXT=hello

FLAG_TRUE          true
FLAG_FALSE         false
FLAG_QUOTED_FALSE  false
FLAG_EMPTY         ''
FLAG_NULL          NULL
FLAG_TEXT          'hello'
FLAG_UNSET         NULL
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note that the quoted &lt;code&gt;"false"&lt;/code&gt; still came back as boolean &lt;code&gt;false&lt;/code&gt;, so quotes do not keep the word as a string. Also note that a key with an empty value (&lt;code&gt;FLAG_EMPTY=&lt;/code&gt;) returns an empty string, which is not the same as &lt;code&gt;null&lt;/code&gt;, and a key that is missing entirely gives &lt;code&gt;null&lt;/code&gt; unless you pass a default. If a setting can legitimately be a plain string like &lt;code&gt;"false"&lt;/code&gt;, don't use those words as values.&lt;/p&gt;

&lt;h2&gt;
  
  
  Spaces need quotes
&lt;/h2&gt;

&lt;p&gt;A value containing spaces must be in double quotes. Without them the app doesn't just misread the value, it refuses to start:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# .env
MY_TITLE=My Application

$ php artisan probe
The environment file is invalid!
Failed to parse dotenv file. Encountered unexpected whitespace at [My Application].
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Writing &lt;code&gt;MY_TITLE="My Application"&lt;/code&gt; fixes it. The docs show the same rule with &lt;code&gt;APP_NAME="My Application"&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The config:cache trap
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;php artisan config:cache&lt;/code&gt; merges all config files into one cached file, which is faster, and you should run it on deploy. But after that, Laravel stops loading &lt;code&gt;.env&lt;/code&gt; on each request, so a direct &lt;code&gt;env()&lt;/code&gt; call outside &lt;code&gt;config/&lt;/code&gt; only sees real system environment variables. Here is the demo. I cached the config, then changed the URL in &lt;code&gt;.env&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ php artisan config:cache
   INFO  Configuration cached successfully.

$ sed -i 's#^PAYMENT_API_URL=.*#PAYMENT_API_URL=https://changed.example.test#' .env

$ php artisan probe
env(PAYMENT_API_URL)         = NULL
config(services.payment.url) = 'https://api.pay.example.test'

$ php artisan config:clear
   INFO  Configuration cache cleared successfully.

$ php artisan probe
env(PAYMENT_API_URL)         = 'https://changed.example.test'
config(services.payment.url) = 'https://changed.example.test'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two lessons in one output. First, &lt;code&gt;env()&lt;/code&gt; in application code returned &lt;code&gt;NULL&lt;/code&gt; while the cache was active, even though the variable is in &lt;code&gt;.env&lt;/code&gt;. That's the production-only bug from the introduction. Second, &lt;code&gt;config()&lt;/code&gt; kept serving the old value, because the cache is a snapshot: changing &lt;code&gt;.env&lt;/code&gt; has no effect until you run &lt;code&gt;config:cache&lt;/code&gt; again (or &lt;code&gt;config:clear&lt;/code&gt; locally). So the deploy order is: update the environment, then rebuild the cache.&lt;/p&gt;

&lt;p&gt;The fix for the bug is always the same. Move the &lt;code&gt;env()&lt;/code&gt; call into a config file, as in the payment example, and read &lt;code&gt;config()&lt;/code&gt; in your code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Environment names and extra env files
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;APP_ENV&lt;/code&gt; names the current environment, and &lt;code&gt;App::environment()&lt;/code&gt; reads it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;Illuminate&lt;/span&gt;\&lt;span class="nc"&gt;Support&lt;/span&gt;\&lt;span class="nc"&gt;Facades&lt;/span&gt;\&lt;span class="nc"&gt;App&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;App&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;environment&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'local'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* ... */&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;App&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;environment&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'local'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'staging'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* local OR staging */&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The docs also describe an environment-specific file: if &lt;code&gt;APP_ENV&lt;/code&gt; is set externally or you pass &lt;code&gt;--env&lt;/code&gt;, Laravel looks for &lt;code&gt;.env.[name]&lt;/code&gt; and loads it instead of &lt;code&gt;.env&lt;/code&gt; if it exists. The word "instead" matters. I created a &lt;code&gt;.env.staging&lt;/code&gt; with only two keys:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.env.staging:
APP_NAME="Staging App"
PAYMENT_API_URL=https://staging.pay.example.test

$ php artisan probe --env=staging
config(services.payment.url)     = 'https://staging.pay.example.test'
config(services.payment.timeout) = 10
config(services.payment.debug)   = false
config(app.name)                 = 'Staging App'
App::environment()               = 'staging'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The timeout and debug flag fell back to their defaults (10 and false) even though &lt;code&gt;.env&lt;/code&gt; sets them to 30 and true: the staging file replaced &lt;code&gt;.env&lt;/code&gt;, it was not layered on top. So a &lt;code&gt;.env.staging&lt;/code&gt; must contain &lt;em&gt;every&lt;/em&gt; variable the app needs. And when the named file does not exist, nothing breaks, you just get the default &lt;code&gt;.env&lt;/code&gt; under a different name:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ APP_ENV=qa php artisan probe       # no .env.qa exists
config(services.payment.url) = 'https://api.pay.example.test'
config(app.name)             = 'Laravel'
App::environment()           = 'qa'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That quietly misleads: the app reports it is in &lt;code&gt;qa&lt;/code&gt; while running on the &lt;code&gt;.env&lt;/code&gt; values.&lt;/p&gt;

&lt;h2&gt;
  
  
  Catching wrong types: the typed getters
&lt;/h2&gt;

&lt;p&gt;Laravel's &lt;code&gt;Config&lt;/code&gt; facade has typed getters that throw when a value is the wrong type, which turns a silent bug into a clear error at the call site:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;Illuminate&lt;/span&gt;\&lt;span class="nc"&gt;Support&lt;/span&gt;\&lt;span class="nc"&gt;Facades&lt;/span&gt;\&lt;span class="nc"&gt;Config&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nv"&gt;$timeout&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Config&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;integer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'services.payment.timeout'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// 30&lt;/span&gt;
&lt;span class="nv"&gt;$url&lt;/span&gt;     &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Config&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'services.payment.url'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nc"&gt;Config&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;integer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'services.payment.url'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                 &lt;span class="c1"&gt;// throws&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Config::integer -&amp;gt; InvalidArgumentException: Configuration value for key [services.payment.url] must be an integer, string given.
Config::boolean -&amp;gt; InvalidArgumentException: Configuration value for key [services.payment.url] must be a boolean, string given.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Keeping secrets out of git: encrypted env files
&lt;/h2&gt;

&lt;p&gt;The docs are clear that &lt;code&gt;.env&lt;/code&gt; should not be committed, since it holds credentials. If you want your environment in source control anyway, Laravel can encrypt it. The commands and the default cipher (AES-256-CBC, which needs a 32-character key) come from the docs. Here is the round trip I ran, with a throwaway key:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ php artisan env:encrypt --key=3UVsEgGVK36XN82KKeyLFMhvosbZN1aF
   INFO  Environment successfully encrypted.
  Key ........ 3UVsEgGVK36XN82KKeyLFMhvosbZN1aF
  Cipher ..... AES-256-CBC
  Encrypted file ..... .env.encrypted

$ php artisan env:decrypt --key=3UVsEgGVK36XN82KKeyLFMhvosbZN1aF
   ERROR  Environment file already exists.

$ rm .env
$ php artisan env:decrypt --key=3UVsEgGVK36XN82KKeyLFMhvosbZN1aF
   INFO  Environment successfully decrypted.
  Decrypted file ..... .env

$ diff .env .env.original &amp;amp;&amp;amp; echo identical
identical
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Decrypting refuses to overwrite an existing &lt;code&gt;.env&lt;/code&gt; unless you pass &lt;code&gt;--force&lt;/code&gt;. On a server you can also set the key in the &lt;code&gt;LARAVEL_ENV_ENCRYPTION_KEY&lt;/code&gt; environment variable instead of passing &lt;code&gt;--key&lt;/code&gt;. With &lt;code&gt;--readable&lt;/code&gt;, variable names stay visible and only values are encrypted, which makes diffs in pull requests much more useful:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ php artisan env:encrypt --readable --force --key=3UVsEgGVK36XN82KKeyLFMhvosbZN1aF
$ cut -c1-40 .env.encrypted | head -3
APP_NAME=eyJpdiI6Ik1VQU5yU1BQa0pGK0VycVZ
APP_ENV=eyJpdiI6IjBpVDZTeFRwOVNxRlUxZGtU
APP_KEY=eyJpdiI6Im53RTkxbG9sS0J3SGtTR0tP
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(The ciphertext differs on every run; yours will look different.) Never commit the key, and don't reuse the key shown here. Store the real one in a password manager or your CI secret store. Per the docs, comments and blank lines from the original file are dropped in the readable form.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common mistakes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;env()&lt;/code&gt;&lt;strong&gt;in controllers, models or services.&lt;/strong&gt; Works locally, returns &lt;code&gt;null&lt;/code&gt; after &lt;code&gt;config:cache&lt;/code&gt;. Read &lt;code&gt;config()&lt;/code&gt; instead.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Forgetting to rebuild the cache on deploy.&lt;/strong&gt; The cache is a snapshot; new &lt;code&gt;.env&lt;/code&gt; values are ignored until you run &lt;code&gt;config:cache&lt;/code&gt; again.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Unquoted values with spaces.&lt;/strong&gt; The app refuses to boot.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Assuming&lt;/strong&gt;&lt;code&gt;.env.staging&lt;/code&gt;&lt;strong&gt;adds to&lt;/strong&gt;&lt;code&gt;.env&lt;/code&gt;&lt;strong&gt;.&lt;/strong&gt; It replaces it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Setting&lt;/strong&gt;&lt;code&gt;APP_ENV&lt;/code&gt;&lt;strong&gt;to a name with no matching file and assuming it is isolated.&lt;/strong&gt; It silently uses &lt;code&gt;.env&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Committing&lt;/strong&gt;&lt;code&gt;.env&lt;/code&gt;&lt;strong&gt;.&lt;/strong&gt; Commit &lt;code&gt;.env.example&lt;/code&gt; with placeholders, as the docs recommend.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Running&lt;/strong&gt;&lt;code&gt;config:cache&lt;/code&gt;&lt;strong&gt;on your dev machine.&lt;/strong&gt; You will chase "my change does nothing" for an hour. Run it on deploy.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Leaving&lt;/strong&gt;&lt;code&gt;APP_DEBUG=true&lt;/code&gt;&lt;strong&gt;in production.&lt;/strong&gt; See the checklist in the &lt;a href="https://dev-talk.com/secure-laravel-applications-before-production" rel="noopener noreferrer"&gt;production security article&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Alternatives to a .env file
&lt;/h2&gt;

&lt;p&gt;On servers, real environment variables (systemd units, Docker's &lt;code&gt;environment&lt;/code&gt; or secrets, your platform's settings page, a secrets manager) avoid keeping a plaintext file on disk at all, and Laravel reads them with the same &lt;code&gt;env()&lt;/code&gt;-in-config pattern. That is a deployment preference rather than a Laravel requirement, so choose what fits your hosting. I only tested &lt;code&gt;.env&lt;/code&gt; and shell variables here.&lt;/p&gt;

&lt;h2&gt;
  
  
  Related Dev Talk articles
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dev-talk.com/post/common-api-design-mistakes" rel="noopener noreferrer"&gt;10 Common API Design Mistakes Developers Make&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Frequently asked questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Can I use env() anywhere if I never run config:cache?
&lt;/h3&gt;

&lt;p&gt;It will work, but you are one deploy script away from the bug. Reading &lt;code&gt;config()&lt;/code&gt; everywhere costs nothing and keeps you safe if caching is switched on later.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why does my .env change not take effect?
&lt;/h3&gt;

&lt;p&gt;Either the config is cached (run &lt;code&gt;php artisan config:clear&lt;/code&gt;), or a real environment variable with the same name is overriding &lt;code&gt;.env&lt;/code&gt;. Check with &lt;code&gt;printenv NAME&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is the difference between .env and .env.example?
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;.env&lt;/code&gt; holds your real values and stays out of git. &lt;code&gt;.env.example&lt;/code&gt; is committed and lists the variable names with placeholders so teammates know what to set.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is the encrypted env file safe to commit?
&lt;/h3&gt;

&lt;p&gt;The docs say encrypted environment files may be placed in source control. The safety depends entirely on keeping the key out of the repository.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://laravel.com/framework/docs/configuration#environment-configuration" rel="noopener noreferrer"&gt;Laravel documentation: Configuration, Environment Configuration&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://dev-talk.com/post/laravel-env-configuration-env-vs-config" rel="noopener noreferrer"&gt;DEV Talk&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>env</category>
      <category>configuration</category>
      <category>configcache</category>
    </item>
    <item>
      <title>Palo Alto PAN-OS CVE-2026-0330: Panorama Root RCE Fix</title>
      <dc:creator>devTalk</dc:creator>
      <pubDate>Sat, 14 Nov 2026 07:40:57 +0000</pubDate>
      <link>https://dev.to/devtalk94/palo-alto-pan-os-cve-2026-0330-panorama-root-rce-fix-4603</link>
      <guid>https://dev.to/devtalk94/palo-alto-pan-os-cve-2026-0330-panorama-root-rce-fix-4603</guid>
      <description>&lt;p&gt;Palo Alto Networks published an advisory on 11 November 2026 for a PAN-OS flaw that lets an attacker run arbitrary code as root. The headline is alarming, and parts of it are justified: root on a security appliance is about as bad as it gets. But the details matter more than the headline. This one is &lt;strong&gt;CVE-2026-0330&lt;/strong&gt;, it affects &lt;strong&gt;Panorama&lt;/strong&gt;, it needs an authenticated administrator, and Palo Alto says it is not aware of any exploitation.&lt;/p&gt;

&lt;p&gt;A different PAN-OS flaw, CVE-2026-0322, was exploited in October and is easy to confuse with this one. Both are covered below so you can tell them apart.&lt;/p&gt;

&lt;h2&gt;
  
  
  The short version
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;What:&lt;/strong&gt; CVE-2026-0330, a code injection flaw (CWE-94) that lets an authenticated administrator with network access run arbitrary code with root privileges.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Where:&lt;/strong&gt; Panorama running PAN-OS 12.2, 12.1, 11.2, 11.1 and 10.2. Cloud NGFW, Prisma Access and standalone PAN-OS firewalls are not affected.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Severity:&lt;/strong&gt; Medium, urgency "moderate" in the advisory, though the base score is high (see below).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Exploited:&lt;/strong&gt; Palo Alto says it is not aware of malicious exploitation. Exploit maturity is listed as unreported.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fix:&lt;/strong&gt; upgrade Panorama to a fixed release. No workaround is known.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What the advisory says
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Item&lt;/th&gt;
&lt;th&gt;Detail (from Palo Alto's advisory)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Weakness&lt;/td&gt;
&lt;td&gt;CWE-94, code injection&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Requirement&lt;/td&gt;
&lt;td&gt;Authenticated administrator with network access. No user interaction. No special configuration needed to be affected&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CVSS 4.0&lt;/td&gt;
&lt;td&gt;CVSS-BT 6.1 (medium), CVSS-B 8.6. If management access is limited to a jump box, the scores drop to BT 5.7 and B 8.4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Exploitation&lt;/td&gt;
&lt;td&gt;"not aware of any malicious exploitation"; exploit maturity: unreported&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Workarounds&lt;/td&gt;
&lt;td&gt;None known&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Published&lt;/td&gt;
&lt;td&gt;11 November 2026; found internally by Palo Alto researcher Daniel Voce&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Why 6.1 and 8.6 at the same time?
&lt;/h3&gt;

&lt;p&gt;One news write-up called those two numbers inconsistent. They aren't. The first, CVSS-BT, is the base score adjusted by threat information: here, exploit maturity "unreported" pulls it down. The second, CVSS-B, is the base score alone, which is high because a successful attack has high impact on confidentiality, integrity and availability. The advisory shows both, and its urgency rating follows the lower, threat-adjusted score. That reading comes from the vector in the advisory (it includes the exploit maturity field), not from an explanation Palo Alto gives, so treat it as my interpretation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Is "attackers can execute code as root" accurate?
&lt;/h2&gt;

&lt;p&gt;Yes, with a condition that the headline drops: the attacker must already be an authenticated administrator who can reach Panorama over the network. This is not an unauthenticated attack from the internet. Its practical meaning is privilege escalation: a user who can log in as an administrator, a stolen admin credential, or a compromised admin session can turn that access into full control of the underlying operating system, below the level the product normally exposes.&lt;/p&gt;

&lt;p&gt;That matters because Panorama manages other firewalls. Root on a management server can mean visibility into, or influence over, the configuration of every device it manages. I'm describing the general role of Panorama here, not a confirmed attack path for this CVE, and the advisory doesn't discuss one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Affected and fixed versions
&lt;/h2&gt;

&lt;p&gt;The advisory lists fixed releases per branch. Find your Panorama's branch, then check you are at or above the fixed hotfix for it:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Branch&lt;/th&gt;
&lt;th&gt;Fixed in (depending on your maintenance release)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;12.2&lt;/td&gt;
&lt;td&gt;12.2.4-h2 or later&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;12.1&lt;/td&gt;
&lt;td&gt;12.1.4-h14, 12.1.7-h12, or 12.1.10-h4 or later&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;11.2&lt;/td&gt;
&lt;td&gt;11.2.4-h24, 11.2.7-h24, 11.2.10-h18, 11.2.13-h5, or 11.2.16-h2 or later&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;11.1&lt;/td&gt;
&lt;td&gt;11.1.4-h39, 11.1.6-h41, 11.1.7-h13, 11.1.10-h37, 11.1.13-h17, or 11.1.16-h5 or later&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;10.2&lt;/td&gt;
&lt;td&gt;10.2.7-h40, 10.2.10-h43, 10.2.13-h28, 10.2.16-h13, or 10.2.18-h14 or later&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Unsupported older versions have no fix; the advisory says to upgrade to a supported fixed release. Read the way hotfix versions work: &lt;code&gt;11.2.7-h24&lt;/code&gt; fixes the 11.2.7 line, and it does not mean &lt;code&gt;11.2.7-h10&lt;/code&gt; is fixed. The "or later" applies within a line, so match your maintenance release first. Where it's ambiguous, trust the advisory page over any table, including this one.&lt;/p&gt;

&lt;p&gt;On the Panorama CLI, the installed version can be read with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;show system info | match sw-version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That is the standard PAN-OS way to display the software version, but I didn't run it against a device. The web interface shows the same value on the dashboard.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reduce exposure while you schedule the upgrade
&lt;/h2&gt;

&lt;p&gt;The advisory states that restricting management access to trusted internal IP addresses significantly reduces the risk, and gives a lower score when access goes through a jump box. In practice:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Never expose Panorama's management interface to the internet or to general user networks.&lt;/li&gt;
&lt;li&gt;Allow management only from a small set of internal addresses or a dedicated jump host. In the PAN-OS web interface this is the management interface's permitted IP addresses setting. Check Palo Alto's documentation for the exact location in your version, as I haven't verified the menu path.&lt;/li&gt;
&lt;li&gt;Reduce the number of administrator accounts, remove stale ones and require MFA where you can. The flaw needs an administrator, so every admin account is part of the attack surface.&lt;/li&gt;
&lt;li&gt;Palo Alto notes that customers with a Threat Prevention subscription get limited coverage from Threat IDs &lt;code&gt;510045&lt;/code&gt; and &lt;code&gt;510048&lt;/code&gt;, and that this requires SSL decryption. It is partial coverage, not a substitute for patching.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The advisory says access restriction reduces risk but doesn't replace the update.&lt;/p&gt;

&lt;h2&gt;
  
  
  Don't mix it up with CVE-2026-0322
&lt;/h2&gt;

&lt;p&gt;The same weeks brought a second, better-known PAN-OS flaw:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;CVE-2026-0322&lt;/th&gt;
&lt;th&gt;CVE-2026-0330&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Product&lt;/td&gt;
&lt;td&gt;PA-Series and VM-Series firewalls, and Panorama&lt;/td&gt;
&lt;td&gt;Panorama only&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Impact&lt;/td&gt;
&lt;td&gt;Authenticated RCE as root on the management interface&lt;/td&gt;
&lt;td&gt;Authenticated RCE as root&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CVSS&lt;/td&gt;
&lt;td&gt;8.6 (as reported)&lt;/td&gt;
&lt;td&gt;CVSS-B 8.6, CVSS-BT 6.1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Exploited&lt;/td&gt;
&lt;td&gt;Yes: "very limited exploitation" reported; added to CISA's KEV catalog&lt;/td&gt;
&lt;td&gt;Not known to be&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Patched&lt;/td&gt;
&lt;td&gt;15 October 2026&lt;/td&gt;
&lt;td&gt;11 November 2026&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The 0322 details come from The Hacker News coverage, not the vendor page, which I couldn't open. If you patched for 0322 in October, you may still need the new Panorama release for 0330. The fixed hotfix numbers differ.&lt;/p&gt;

&lt;p&gt;The Hacker News also lists three IP addresses that Palo Alto assessed as linked to the 0322 activity: &lt;code&gt;66.42.72.14&lt;/code&gt;, &lt;code&gt;208.83.239.114&lt;/code&gt; and &lt;code&gt;149.248.47.234&lt;/code&gt;. If you keep management-interface access logs, a quick look is cheap:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;grep -E -w &lt;span class="s1"&gt;'66\.42\.72\.14|208\.83\.239\.114|149\.248\.47\.234'&lt;/span&gt; /path/to/your/access.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No hits don't mean you are clean (attackers change addresses), and these are not indicators for CVE-2026-0330. The &lt;code&gt;-w&lt;/code&gt; flag makes &lt;code&gt;66.42.72.14&lt;/code&gt; not match &lt;code&gt;66.42.72.145&lt;/code&gt;. I tested the command against a sample log.&lt;/p&gt;

&lt;h2&gt;
  
  
  A sensible order of operations
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Inventory every Panorama (physical and virtual) and its PAN-OS version.&lt;/li&gt;
&lt;li&gt;Check that none are reachable from untrusted networks, and fix that first. It takes minutes.&lt;/li&gt;
&lt;li&gt;Schedule upgrades to the fixed release for each branch, starting with the most exposed.&lt;/li&gt;
&lt;li&gt;Review administrator accounts, API keys and recent admin logins.&lt;/li&gt;
&lt;li&gt;After the upgrade, confirm the new version and that managed devices still check in.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Common mistakes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Assuming "medium" means "can wait" on a device with root-level impact. A moderate score reflects the admin requirement and no known exploitation, not harmlessness.&lt;/li&gt;
&lt;li&gt;Confusing the two CVEs, and patching only one.&lt;/li&gt;
&lt;li&gt;Checking firewalls but forgetting Panorama.&lt;/li&gt;
&lt;li&gt;Applying the wrong hotfix for your maintenance line.&lt;/li&gt;
&lt;li&gt;Treating a management interface behind a VPN as safe without limiting who can log in.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Frequently asked questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Does CVE-2026-0330 affect my PA-Series firewall?
&lt;/h3&gt;

&lt;p&gt;According to the advisory, standalone PAN-OS firewalls, Cloud NGFW and Prisma Access are not affected by this CVE. CVE-2026-0322 is the one that covers firewalls.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is it exploited in the wild?
&lt;/h3&gt;

&lt;p&gt;Palo Alto says it is not aware of any malicious exploitation of CVE-2026-0330. That can change, so check the advisory page.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can an unauthenticated attacker use it?
&lt;/h3&gt;

&lt;p&gt;The advisory requires an authenticated administrator with network access.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is there a workaround?
&lt;/h3&gt;

&lt;p&gt;None known. Restricting management access lowers risk but does not fix the flaw.&lt;/p&gt;

&lt;h2&gt;
  
  
  Related Dev Talk articles
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dev-talk.com/post/chrome-zero-day-cve-2026-125350-update-check" rel="noopener noreferrer"&gt;Chrome Zero-Day CVE-2026-125350: What It Is, Who Is Affected and How to Update&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev-talk.com/post/cursor-claude-code-extension-backdoor-what-to-check" rel="noopener noreferrer"&gt;Malicious Claude Code Extension in the Cursor Marketplace: What Happened and How to Check Your Machine&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://security.paloaltonetworks.com/CVE-2026-0330" rel="noopener noreferrer"&gt;Palo Alto Networks: CVE-2026-0330 advisory&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://cybersecuritynews.com/palo-alto-networks-pan-os-rce-vulnerability/" rel="noopener noreferrer"&gt;Cyber Security News: Palo Alto Networks PAN-OS RCE Vulnerability&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://thehackernews.com/2026/10/palo-alto-networks-patches-pan-os.html" rel="noopener noreferrer"&gt;The Hacker News: Palo Alto Networks patches PAN-OS authenticated RCE flaw (CVE-2026-0322)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://dev-talk.com/post/palo-alto-pan-os-cve-2026-0330-panorama-rce" rel="noopener noreferrer"&gt;DEV Talk&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>security</category>
      <category>paloalto</category>
      <category>panos</category>
      <category>panorama</category>
    </item>
    <item>
      <title>Chrome Zero-Day CVE-2026-125350: Update and Check</title>
      <dc:creator>devTalk</dc:creator>
      <pubDate>Sat, 14 Nov 2026 05:57:57 +0000</pubDate>
      <link>https://dev.to/devtalk94/chrome-zero-day-cve-2026-125350-update-and-check-2kkn</link>
      <guid>https://dev.to/devtalk94/chrome-zero-day-cve-2026-125350-update-and-check-2kkn</guid>
      <description>&lt;p&gt;Google has patched another Chrome vulnerability that attackers were already exploiting. It is tracked as &lt;strong&gt;CVE-2026-125350&lt;/strong&gt;, a use-after-free bug in Chrome's XML component, and the fix shipped on 9 November 2026. If your browser is older than the fixed build, a web page can be enough to trigger it.&lt;/p&gt;

&lt;p&gt;The headlines say "execute malicious code remotely", which is true but easy to over-read. This article explains what has actually been confirmed, what has not, which versions are safe, and how to check every Chromium-based browser you and your team run, including the ones that don't look like browsers.&lt;/p&gt;

&lt;h2&gt;
  
  
  The short version
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Bug:&lt;/strong&gt; CVE-2026-125350, use-after-free (CWE-416) in Chrome's XML component, rated High by Chrome.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Exploited:&lt;/strong&gt; Google says it is aware that an exploit for this CVE exists in the wild.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fixed in:&lt;/strong&gt; Stable 157.0.8103.50 (Linux) and 157.0.8103.50/.51 (Windows, macOS); Extended Stable 156.0.8078.96.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Your action:&lt;/strong&gt; update, then &lt;strong&gt;relaunch&lt;/strong&gt; the browser. The fix does not apply until the restart.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What is confirmed
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Item&lt;/th&gt;
&lt;th&gt;Detail&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;CVE&lt;/td&gt;
&lt;td&gt;CVE-2026-125350&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Component and type&lt;/td&gt;
&lt;td&gt;XML, use-after-free&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Reported&lt;/td&gt;
&lt;td&gt;6 November 2026, by an anonymous researcher&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Fixed and disclosed&lt;/td&gt;
&lt;td&gt;9 November 2026 (Chrome Stable channel update)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CISA KEV&lt;/td&gt;
&lt;td&gt;Added 10 November 2026, with a due date of 24 November for US federal civilian agencies&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Severity&lt;/td&gt;
&lt;td&gt;High (Chrome). CVSS 3.1 base score 8.8, scored by CISA, per two security news sites&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Affected&lt;/td&gt;
&lt;td&gt;Chrome builds before 157.0.8103.50, per the CVE record&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Same release&lt;/td&gt;
&lt;td&gt;Nine security fixes in total. Another XML use-after-free, CVE-2026-125346, is in the same update, but the in-the-wild statement applies only to CVE-2026-125350&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  What "remote code execution" means here
&lt;/h2&gt;

&lt;p&gt;This is where the headlines run ahead of the evidence. The CISA catalog entry, as quoted by one write-up, describes a remote attacker running code &lt;strong&gt;inside the sandbox&lt;/strong&gt; through a crafted web page. Chrome's sandbox is a separate layer that limits what a compromised renderer can do to the rest of the machine. A sandbox escape or full device compromise has not been publicly confirmed for this bug.&lt;/p&gt;

&lt;p&gt;That is still serious. Real attacks on browsers are usually chains: one bug to get code running in the renderer, and a second one to break out. A bug exploited in the wild is often the first link of such a chain, though nobody has published what the second link was here. Treat the missing information as unknown, not as a reason to wait.&lt;/p&gt;

&lt;p&gt;It also needs a user to visit a page. No account, no credentials, no prior access: just a link, an ad, a compromised site or an embedded frame. Google and CISA have not said who is using the exploit or against whom, so don't assume you are not a target because you are not a high-profile one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why a use-after-free bug is dangerous
&lt;/h2&gt;

&lt;p&gt;A use-after-free happens when code keeps using memory after it has been released. If an attacker can control what gets placed in that freed memory, the program may end up reading or running attacker-chosen data. Browsers parse untrusted input constantly, in a language (C++) where this class of mistake is possible, so they see a steady supply of such bugs. That is why Chrome security updates arrive so often, and why running an old build is the real risk, not any single CVE.&lt;/p&gt;

&lt;p&gt;BleepingComputer's headline calls this the eighth Chrome zero-day exploited in attacks this year. I could only read the headline, not the article, so I'm quoting it as reported.&lt;/p&gt;

&lt;h2&gt;
  
  
  Check your version in one minute
&lt;/h2&gt;

&lt;p&gt;The fastest check is the browser itself: open &lt;code&gt;chrome://version&lt;/code&gt;, or go to Help, then About Google Chrome, which also triggers the update download. Look for &lt;code&gt;157.0.8103.50&lt;/code&gt; or newer.&lt;/p&gt;

&lt;p&gt;From a terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Linux&lt;/span&gt;
google-chrome --version

&lt;span class="c"&gt;# macOS&lt;/span&gt;
&lt;span class="s2"&gt;"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"&lt;/span&gt; --version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Windows (default install path)&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Item&lt;/span&gt; &lt;span class="s2"&gt;"C:\Program Files\Google\Chrome\Application\chrome.exe"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;VersionInfo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;ProductVersion&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To compare it against the fixed build in a script (a fleet audit, a CI image check), here is a small helper. It accepts either the whole version string or just the number:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;
&lt;span class="c"&gt;# usage: ./chk.sh "&amp;lt;version output from the browser&amp;gt;"&lt;/span&gt;
&lt;span class="c"&gt;# Fixed builds for CVE-2026-125350: Stable 157.0.8103.50 or newer,&lt;/span&gt;
&lt;span class="c"&gt;# Extended Stable 156.0.8078.96 or newer.&lt;/span&gt;
&lt;span class="nv"&gt;CUR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"$(echo "&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="s2"&gt;" | grep -oE '[0-9]+(\.[0-9]+){3}' | head -1)"&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt; -z &lt;span class="s2"&gt;"$CUR"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"no version found in: $1"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;exit&lt;/span&gt; 2&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;
ge&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"$(printf '%s\n%s\n' "&lt;/span&gt;&lt;span class="nv"&gt;$2&lt;/span&gt;&lt;span class="s2"&gt;" "&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="s2"&gt;" | sort -V | head -1)"&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"$2"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="nv"&gt;MAJOR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"${CUR%%.*}"&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"$MAJOR"&lt;/span&gt; -ge 157 &lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; ge &lt;span class="s2"&gt;"$CUR"&lt;/span&gt; 157.0.8103.50&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"$CUR: has the fix"&lt;/span&gt;
&lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"$MAJOR"&lt;/span&gt; -eq 156 &lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; ge &lt;span class="s2"&gt;"$CUR"&lt;/span&gt; 156.0.8078.96&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"$CUR: has the fix (Extended Stable line)"&lt;/span&gt;
&lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"$MAJOR"&lt;/span&gt; -gt 157 &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"$CUR: newer major, assume fixed"&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"$CUR: older than the fixed builds, update"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Running it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ ./chk.sh "Google Chrome 156.0.8078.96"
156.0.8078.96: has the fix (Extended Stable line)
$ ./chk.sh "157.0.8103.9"
157.0.8103.9: older than the fixed builds, update
$ ./chk.sh "153.0.8010.12"
153.0.8010.12: older than the fixed builds, update
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The comparison uses &lt;code&gt;sort -V&lt;/code&gt;, which compares dotted numbers correctly, so &lt;code&gt;157.0.8103.9&lt;/code&gt; is treated as older than &lt;code&gt;157.0.8103.50&lt;/code&gt;. A plain string comparison would get that wrong. I tested the script against those cases, including a version-less input, which exits with an error.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to update
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Desktop Chrome (Windows, macOS):&lt;/strong&gt; Help, About Google Chrome, then &lt;strong&gt;Relaunch&lt;/strong&gt;. Chrome downloads updates in the background, but the fix takes effect only after a restart. A browser that has run for weeks with a pending update is still vulnerable.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Linux:&lt;/strong&gt; use the package manager. For Google's apt repository, that is &lt;code&gt;sudo apt update &amp;amp;&amp;amp; sudo apt install --only-upgrade google-chrome-stable&lt;/code&gt;, then restart the browser. Use the equivalent command for your distribution if you installed Chromium from a distro package, and check that its maintainers have shipped the fix.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Android:&lt;/strong&gt; update through Google Play. One report lists the Android build as 157.0.8103.50, but the Android advisory does not list this CVE individually, so confirm the version on your own device.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Managed fleets:&lt;/strong&gt; use your endpoint management tool to read installed versions, and consider Chrome's enterprise relaunch notification policies so users are not left on a pending update indefinitely. Check the current policy documentation for exact names and behavior, since I did not test them.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Other Chromium browsers and apps
&lt;/h2&gt;

&lt;p&gt;The vulnerable code lives in Chromium, the open-source engine, so Edge, Brave, Opera, Vivaldi and others may be affected until they ship a build based on the fix. Each vendor patches on its own schedule. Two data points from the sources I read:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Microsoft's Edge release notes of 9 November said it was aware of exploits in the wild and was working on a fix, without naming the CVE, according to a secondary write-up. Check the Edge security notes for the current fixed build.&lt;/li&gt;
&lt;li&gt;I did not find a confirmed fixed version for Opera, Vivaldi or Brave in what I read. Look up each vendor's own advisory rather than assuming.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As developers we also run Chromium in places that don't look like browsers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Playwright, Puppeteer and Selenium test browsers.&lt;/strong&gt; They download pinned Chromium builds. In my test environment, Playwright's bundled Chromium reported &lt;code&gt;153.0.8010.12&lt;/code&gt;, which is older than the fixed build. By the CVE's affected range that means it does not contain this fix. I did not test whether the exploit works against it. If your CI browses untrusted pages (scraping, link checking, screenshot services), update the browser package and the cached browser downloads.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Electron apps.&lt;/strong&gt; Each app bundles its own Chromium. Whether an app is exposed depends on its Electron version and on whether it loads untrusted content. Look at the vendor's release notes rather than your installed Chrome.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Headless Chrome in containers.&lt;/strong&gt; A Docker image built months ago keeps the browser version it was built with. Rebuild images that include Chrome or Chromium.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  If you can't patch right away
&lt;/h2&gt;

&lt;p&gt;Patching is the fix. Everything below only reduces exposure, and none of it replaces updating:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Close long-running browser sessions and restart the browser, so a downloaded update is actually applied.&lt;/li&gt;
&lt;li&gt;Avoid opening untrusted links from email and chat on unpatched machines.&lt;/li&gt;
&lt;li&gt;Keep browser isolation features and the sandbox enabled. Don't launch Chrome with &lt;code&gt;--no-sandbox&lt;/code&gt; outside a throwaway container, and if CI needs it, keep that CI away from untrusted pages.&lt;/li&gt;
&lt;li&gt;Restrict unapproved extensions, and use DNS or web-gateway filtering if your organization has them.&lt;/li&gt;
&lt;li&gt;Watch endpoint telemetry for unusual browser child processes, repeated browser crashes and odd outbound connections.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Common mistakes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Updating without relaunching.&lt;/li&gt;
&lt;li&gt;Checking only Chrome and forgetting Edge, Brave, Electron apps and CI browsers.&lt;/li&gt;
&lt;li&gt;Assuming a sandboxed bug is harmless, or assuming it means total compromise. Neither is established.&lt;/li&gt;
&lt;li&gt;Waiting for details of the exploit before patching.&lt;/li&gt;
&lt;li&gt;Reading the CISA deadline as applying to everyone. The 24 November date is for US federal civilian agencies; for everyone else it is a useful priority signal.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Frequently asked questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Is CVE-2026-125350 being exploited right now?
&lt;/h3&gt;

&lt;p&gt;Google says it is aware that an exploit exists in the wild. It has not disclosed who is using it or how widely.&lt;/p&gt;

&lt;h3&gt;
  
  
  Do I need to do anything if Chrome updates itself?
&lt;/h3&gt;

&lt;p&gt;Yes: relaunch. Check &lt;code&gt;chrome://version&lt;/code&gt; afterwards and confirm the number is at least &lt;code&gt;157.0.8103.50&lt;/code&gt; (or &lt;code&gt;156.0.8078.96&lt;/code&gt; on Extended Stable).&lt;/p&gt;

&lt;h3&gt;
  
  
  Does it affect Firefox or Safari?
&lt;/h3&gt;

&lt;p&gt;The sources I read describe a Chrome and Chromium bug. I did not find anything saying Firefox or Safari are affected, but I did not test them.&lt;/p&gt;

&lt;h3&gt;
  
  
  Did the attackers escape the sandbox?
&lt;/h3&gt;

&lt;p&gt;Not publicly confirmed. Code execution in the sandbox is the confirmed description.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do I know if I was attacked?
&lt;/h3&gt;

&lt;p&gt;There are no public indicators of compromise that I could find. Google has not published any attacker details. The practical response is to patch and review endpoint telemetry for unusual browser behavior.&lt;/p&gt;

&lt;h2&gt;
  
  
  Related Dev Talk articles
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dev-talk.com/post/cursor-claude-code-extension-backdoor-what-to-check" rel="noopener noreferrer"&gt;Malicious Claude Code Extension in the Cursor Marketplace: What Happened and How to Check Your Machine&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://cybersecuritynews.com/google-chrome-0-day-exploited/" rel="noopener noreferrer"&gt;Cyber Security News: Google Chrome 0-Day Vulnerability in the Wild to Execute Malicious Code Remotely&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://socprime.com/blog/cve-2026-125350-chrome-xml-zero-day-exploited-in-the-wild/" rel="noopener noreferrer"&gt;SOC Prime: CVE-2026-125350, Chrome XML Zero-Day Exploited in the Wild&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.esecurityplanet.com/news/news-google-chrome-zero-day-patch/" rel="noopener noreferrer"&gt;eSecurity Planet: Google Patches Exploited Chrome Zero-Day&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://braindetox.kr/en/posts/chrome_cve_2026_125350_kev.html" rel="noopener noreferrer"&gt;braindetox.kr: Chrome CVE-2026-125350 in KEV&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.bleepingcomputer.com/news/security/google-patches-eighth-chrome-zero-day-exploited-in-attacks-this-year/" rel="noopener noreferrer"&gt;BleepingComputer: Google patches eighth Chrome zero-day exploited in attacks this year&lt;/a&gt; (headline only)&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://dev-talk.com/post/chrome-zero-day-cve-2026-125350-update-check" rel="noopener noreferrer"&gt;DEV Talk&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>security</category>
      <category>chrome</category>
      <category>zeroday</category>
      <category>cve</category>
    </item>
    <item>
      <title>Malicious Claude Code Extension in Cursor: Check Your Machine</title>
      <dc:creator>devTalk</dc:creator>
      <pubDate>Sat, 14 Nov 2026 05:20:14 +0000</pubDate>
      <link>https://dev.to/devtalk94/malicious-claude-code-extension-in-cursor-check-your-machine-1b05</link>
      <guid>https://dev.to/devtalk94/malicious-claude-code-extension-in-cursor-check-your-machine-1b05</guid>
      <description>&lt;p&gt;If you use Cursor and had the Claude Code extension installed on 29 October 2026, there is a real chance you ran a backdoored copy of it. Headlines have described this as "Anthropic hacked", and that is not what the vendor reports say. This post separates what has been confirmed from what has been claimed, and gives you a short, practical checklist.&lt;/p&gt;

&lt;p&gt;The short version: a modified build of the extension sat in &lt;strong&gt;Cursor's&lt;/strong&gt; extension marketplace for about 11 hours. It tried to give an attacker SSH access to the developer's machine. Cursor says Anthropic did not publish it and that its product was not vulnerable.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is confirmed
&lt;/h2&gt;

&lt;p&gt;These points come from Cursor's own notices, with Sophos and other security vendors repeating them:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Affected versions:&lt;/strong&gt; &lt;code&gt;Anthropic.claude-code&lt;/code&gt; 2.1.312 and 2.1.313, on Windows and macOS, from the Cursor VS Code extension marketplace. Cursor's first notice named 2.1.313; it was updated on 30 October to include 2.1.312.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Window:&lt;/strong&gt; about 09:27 to 20:35 UTC on 29 October 2026 (Cursor gives it as roughly 2:27 am to 1:35 pm Pacific).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Exposure:&lt;/strong&gt; Cursor estimates up to 5,000 users. It describes these as users who requested the specific cached versions that day.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Who built it:&lt;/strong&gt; Cursor states that the malicious versions "were not developed by Anthropic."&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Was Anthropic hacked?
&lt;/h2&gt;

&lt;p&gt;Based on Cursor's incident update (13 November), no. Cursor says an attacker used a credential taken from Cursor's own internal data to place unauthorized copies of the extension on the cache that serves its marketplace. It says Anthropic did not publish this copy, this was not a vulnerability in Anthropic's product, and the upstream source, Open VSX, never had the malware.&lt;/p&gt;

&lt;p&gt;The same update describes how the attacker got that credential: an access key Cursor had issued to a third-party inference provider, Fireworks, which Cursor says was exposed by Fireworks. The attacker used it to copy data from a read-only storage bucket, and some stored traces contained unredacted credentials. I have only Cursor's account of this chain. Treat it as the vendor's statement, not independent confirmation.&lt;/p&gt;

&lt;p&gt;I could not open the Doublepulsar article that prompted this post, so I can't say how it frames the incident. If you have read it, compare its claims against Cursor's notices linked at the end.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the malicious build does
&lt;/h2&gt;

&lt;p&gt;According to Cursor, it:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Collects host and user details (hostname, username, OS, architecture, home directory, environment variable &lt;em&gt;names&lt;/em&gt;, working directories, Git email and public IP) and sends them to an attacker's server.&lt;/li&gt;
&lt;li&gt;Tries to add an attacker-controlled SSH key, enable SSH and open a reverse tunnel. Cursor says this would usually fail without administrator rights.&lt;/li&gt;
&lt;li&gt;Tries to persist through a LaunchAgent on macOS or a scheduled task on Windows, retrying about every 60 seconds.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Note the word "tries". Sophos, citing an analysis by Phorion, says coding errors made SSH enablement fail on most macOS and Windows hosts. That limits the damage on many machines, but it is not a reason to skip the checks. Environment variable names alone can tell an attacker what cloud providers and services you use.&lt;/p&gt;

&lt;p&gt;Cursor says the attacker's server has been taken offline. That means blocking the IP is of limited use now, but its logs and your own are still useful for working out whether a machine connected.&lt;/p&gt;

&lt;h2&gt;
  
  
  Check whether you were affected
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Did you have the extension in Cursor on 29 October?&lt;/strong&gt; Look at your installed extensions and the version. If you only use Claude Code in VS Code from Microsoft's marketplace, or in a terminal, these notices do not cover you.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Look for the planted SSH key.&lt;/strong&gt; Cursor's notice names the key comment &lt;code&gt;svc-telemetry&lt;/code&gt;. On macOS or Linux:&lt;code&gt;grep -n 'svc-telemetry' ~/.ssh/authorized_keys&lt;/code&gt; No output (or "No such file") means that key is not there. A matching line means the key was added.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Look at running processes and persistence.&lt;/strong&gt; Cursor provides platform-specific remediation scripts (&lt;code&gt;remediate-macos.sh&lt;/code&gt; and &lt;code&gt;remediate-windows.ps1&lt;/code&gt;) and the full list of indicators. Use those rather than a checklist copied from a blog, including this one, because indicators were updated after the first notice.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;On Windows, Cursor gives an equivalent PowerShell check for the user's and ProgramData's &lt;code&gt;authorized_keys&lt;/code&gt; files. Get it from the notice itself.&lt;/p&gt;

&lt;h2&gt;
  
  
  If you find something
&lt;/h2&gt;

&lt;p&gt;Cursor's advice, in order of priority:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Isolate the machine&lt;/strong&gt; if there are signs the code ran or a backdoor was installed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Do not rely on uninstalling the extension.&lt;/strong&gt; Cursor warns that uninstalling may not be enough because standalone persistence scripts can keep running. Remove the unauthorized key, the persistence entries and the tunnel processes. Consider rebuilding the host.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rotate credentials and sessions&lt;/strong&gt; that were reachable from that machine, doing it from a trusted system. Start with SSH keys, cloud provider keys, API tokens and anything stored in environment variables or &lt;code&gt;.env&lt;/code&gt; files.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you have no sign of the key and no sign of the persistence entries, a precautionary rotation of the most sensitive credentials is still cheap compared with the alternative.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lessons for the rest of us
&lt;/h2&gt;

&lt;p&gt;These are my recommendations, not findings from the incident:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Extensions run with your privileges.&lt;/strong&gt; They can read your environment, your SSH directory and your project secrets. Treat an editor extension update like a dependency update, not like a theme change.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Auto-update is a trade-off.&lt;/strong&gt; It gets you security fixes quickly, but it also delivers a bad build quickly. For machines that hold production credentials, consider managing extension versions deliberately.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keep production secrets off developer laptops.&lt;/strong&gt; Short-lived credentials, a secrets manager and separate deploy keys limit what a compromised editor can reach. Our &lt;a href="https://dev-talk.com/post/github-actions-laravel-deploy-ssh-releases-rollback" rel="noopener noreferrer"&gt;SSH deploy article&lt;/a&gt; uses a dedicated deploy key for that reason.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Watch your&lt;/strong&gt;&lt;code&gt;authorized_keys&lt;/code&gt;&lt;strong&gt;.&lt;/strong&gt; A new key you didn't add is a high-signal alert on any machine, and it is simple to monitor.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Supply-chain risk follows the tooling.&lt;/strong&gt; A malicious build under a trusted vendor's name is exactly the case where checking the publisher alone is not enough.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Common mistakes during cleanup
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Uninstalling the extension and stopping there.&lt;/li&gt;
&lt;li&gt;Rotating credentials from the possibly compromised machine.&lt;/li&gt;
&lt;li&gt;Assuming you are safe because you use the Microsoft marketplace. The notices concern the Cursor marketplace only; check where your copy came from.&lt;/li&gt;
&lt;li&gt;Searching only for one version number. Cursor extended the affected versions after its first notice.&lt;/li&gt;
&lt;li&gt;Relying on the attacker IP alone, since the server was taken down.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Related Dev Talk articles
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dev-talk.com/post/laravel-production-mistakes" rel="noopener noreferrer"&gt;5 Laravel Production Mistakes That Pass Every Local Test&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Frequently asked questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Does this affect the Claude Code CLI or the extension in VS Code?
&lt;/h3&gt;

&lt;p&gt;The notices I read describe the Cursor marketplace copy only. Cursor says there is no evidence that other versions of the extension or the official distribution are affected. I did not test any of this.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is it a remote access trojan?
&lt;/h3&gt;

&lt;p&gt;Cursor describes an attempt to add an SSH key and open a reverse tunnel, which would give an attacker remote access if it worked. I haven't seen the term "remote access trojan" in the vendor notices I read, so I use their wording.&lt;/p&gt;

&lt;h3&gt;
  
  
  Which version should I be on now?
&lt;/h3&gt;

&lt;p&gt;Follow Cursor's current notice. One third-party advisory I read mentioned 2.1.314 as the fixed version, but I couldn't verify that, and updating alone does not remove anything already planted.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://cursor.com/blog/claude-code-extension-security-notice" rel="noopener noreferrer"&gt;Cursor: security notice, malicious Anthropic.claude-code versions in the Cursor marketplace&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://cursor.com/blog/security-incident-update" rel="noopener noreferrer"&gt;Cursor: an update on our recent security incident&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.sophos.com/en-us/blog/malicious-claude-code-extension-distributed-through-cursor-marketplace" rel="noopener noreferrer"&gt;Sophos: malicious Claude Code extension distributed through Cursor marketplace&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://dev-talk.com/post/cursor-claude-code-extension-backdoor-what-to-check" rel="noopener noreferrer"&gt;DEV Talk&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>security</category>
      <category>supplychain</category>
      <category>cursor</category>
      <category>claudecode</category>
    </item>
    <item>
      <title>10 Common API Design Mistakes</title>
      <dc:creator>devTalk</dc:creator>
      <pubDate>Sat, 14 Nov 2026 03:15:18 +0000</pubDate>
      <link>https://dev.to/devtalk94/10-common-api-design-mistakes-5cej</link>
      <guid>https://dev.to/devtalk94/10-common-api-design-mistakes-5cej</guid>
      <description>&lt;p&gt;&lt;em&gt;Last updated: 9 November 2026. See the&lt;/em&gt;&lt;em&gt;update log&lt;/em&gt;&lt;em&gt;at the end.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Most API problems don't show up on launch day. They show up months later, when a mobile app can't be updated because a field changed type, when a retry double-charges a customer, when a support ticket turns out to be one user reading another user's order. The code worked. The &lt;em&gt;design&lt;/em&gt; was the bug, and by then a hundred clients depend on it.&lt;/p&gt;

&lt;p&gt;This article covers ten mistakes that I see repeated in REST-style JSON APIs, with a small demo server behind each one so the symptom is real output rather than a claim. Every mistake comes with the fix, and where the fix is written down in a standard (HTTP semantics, Problem Details, the deprecation headers) I checked the standard instead of quoting from memory. The demo servers are plain Node, so nothing here depends on a framework; the PHP/Laravel snippets show how the fixes map to the stack many readers use.&lt;/p&gt;

&lt;h2&gt;
  
  
  The ten at a glance
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;#&lt;/th&gt;
&lt;th&gt;Mistake&lt;/th&gt;
&lt;th&gt;The fix in one line&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;Returning &lt;code&gt;200 OK&lt;/code&gt; for errors&lt;/td&gt;
&lt;td&gt;Use the status code, let clients branch on it&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;A different error shape on every endpoint&lt;/td&gt;
&lt;td&gt;One format, ideally &lt;code&gt;application/problem+json&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;Ignoring HTTP method semantics&lt;/td&gt;
&lt;td&gt;Match method to safe / idempotent behavior&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;Unbounded lists and offset pagination&lt;/td&gt;
&lt;td&gt;Always paginate; use cursors for changing data&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;Retries that create duplicates&lt;/td&gt;
&lt;td&gt;Idempotency keys for non-idempotent writes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;Breaking changes with no warning&lt;/td&gt;
&lt;td&gt;Additive changes, plus &lt;code&gt;Deprecation&lt;/code&gt; and &lt;code&gt;Sunset&lt;/code&gt; headers&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;td&gt;No object-level authorization&lt;/td&gt;
&lt;td&gt;Check ownership on every object access&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;Exposing and accepting whole models&lt;/td&gt;
&lt;td&gt;Explicit response shapes and allow-listed input&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;9&lt;/td&gt;
&lt;td&gt;No rate limiting&lt;/td&gt;
&lt;td&gt;Limit, and answer &lt;code&gt;429&lt;/code&gt; with &lt;code&gt;Retry-After&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;td&gt;Sloppy data conventions: money, dates, naming&lt;/td&gt;
&lt;td&gt;Integer minor units, RFC 3339 timestamps, one naming style&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  1. Returning 200 OK for errors
&lt;/h2&gt;

&lt;p&gt;It looks harmless and it is one of the most expensive habits. The endpoint returns &lt;code&gt;200&lt;/code&gt; and puts the failure in the body:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ curl -si localhost:4040/bad/users/999
HTTP/1.1 200 OK
Content-Type: application/json

{"success":false,"error":"User not found"}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Everything between your server and the client's code treats that as a success: HTTP clients that only throw on 4xx/5xx, retry logic, monitoring that counts error rates from status codes, caches, and the browser's network panel. Your dashboards say the API is 100% healthy while users see "not found". Every client team also has to learn your private convention for finding the real outcome.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ curl -si localhost:4040/good/users/999
HTTP/1.1 404 Not Found
Content-Type: application/problem+json

{"type":"https://api.example.com/problems/user-not-found","title":"User not found","status":404,"detail":"No user with id 999.","instance":"/good/users/999"}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The status codes you need most are all defined in RFC 9110: &lt;code&gt;201 Created&lt;/code&gt; for a successful create, &lt;code&gt;204 No Content&lt;/code&gt; for success without a body, &lt;code&gt;400&lt;/code&gt; for a malformed request, &lt;code&gt;401&lt;/code&gt; and &lt;code&gt;403&lt;/code&gt; for authentication and permission problems, &lt;code&gt;404&lt;/code&gt;, &lt;code&gt;409 Conflict&lt;/code&gt;, and &lt;code&gt;422&lt;/code&gt; for a well-formed request that fails validation. The spec's current name for 422 is "Unprocessable Content". (My Node server still prints the older phrase "Unprocessable Entity" in the status line, which is only a label; the number is what matters.) Rate limiting uses &lt;code&gt;429&lt;/code&gt;, which comes from RFC 6585, and gets its own section below.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. A different error format on every endpoint
&lt;/h2&gt;

&lt;p&gt;Even with correct status codes, clients suffer when one endpoint returns &lt;code&gt;{"error": "..."}&lt;/code&gt;, another &lt;code&gt;{"message": "...", "code": 12}&lt;/code&gt;, and a third a bare string. Pick one shape. You don't need to invent it: RFC 9457, "Problem Details for HTTP APIs", defines one, and it replaced RFC 7807.&lt;/p&gt;

&lt;p&gt;Per the RFC, the media type is &lt;code&gt;application/problem+json&lt;/code&gt; and the standard members are all optional:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;type&lt;/code&gt;: a URI that identifies the kind of problem. If it is absent, clients assume &lt;code&gt;about:blank&lt;/code&gt;, meaning "nothing beyond the HTTP status".&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;status&lt;/code&gt;: the HTTP status code. Generators must send the same code in the actual response; consumers treat the member as advisory, since a proxy could change the real status.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;title&lt;/code&gt;: a short summary of the problem type that stays the same across occurrences.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;detail&lt;/code&gt;: an explanation of this specific occurrence, meant to help the client fix the problem.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;instance&lt;/code&gt;: a URI identifying this particular occurrence.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can add your own members, such as an &lt;code&gt;errors&lt;/code&gt; array for per-field validation failures. Clients must ignore extension members they don't recognize, so adding them later doesn't break anyone. Keep &lt;code&gt;detail&lt;/code&gt; useful to the caller and free of stack traces and SQL; the RFC says it is meant to help the client fix the problem rather than to provide debugging information.&lt;/p&gt;

&lt;p&gt;Whatever your framework returns by default for a 404 or a validation failure, call two or three endpoints with &lt;code&gt;curl -i&lt;/code&gt; and look at the shapes. If they differ, that is the work.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Ignoring HTTP method semantics
&lt;/h2&gt;

&lt;p&gt;Two properties from RFC 9110 matter in practice. A &lt;em&gt;safe&lt;/em&gt; method is essentially read-only: of the methods defined there, GET, HEAD, OPTIONS and TRACE are safe. An &lt;em&gt;idempotent&lt;/em&gt; method has the same intended effect whether it is sent once or many times: PUT, DELETE and the safe methods are idempotent. POST is not on that list.&lt;/p&gt;

&lt;p&gt;Why you care: clients, proxies and browsers act on these properties. A client may retry an idempotent request automatically after a connection failure, and a crawler or link prefetcher can follow a GET without anyone clicking. So these designs go wrong:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;GET /orders/42/cancel&lt;/code&gt; or &lt;code&gt;GET /users/7/delete&lt;/code&gt;: a state change behind a safe method. Anything that fetches the URL, including a prefetcher or a monitoring probe, triggers it.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;POST /getUser&lt;/code&gt;, &lt;code&gt;POST /updateUser&lt;/code&gt;, &lt;code&gt;POST /deleteUser&lt;/code&gt;: everything funneled through POST, so no caching of reads and no automatic retry of anything.&lt;/li&gt;
&lt;li&gt;A &lt;code&gt;PUT&lt;/code&gt; that appends instead of replacing, so a retry applies the change twice and the "idempotent" label lies.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The straightforward mapping: &lt;code&gt;GET /orders/42&lt;/code&gt; reads, &lt;code&gt;POST /orders&lt;/code&gt; creates, &lt;code&gt;PUT /orders/42&lt;/code&gt; replaces, &lt;code&gt;DELETE /orders/42&lt;/code&gt; removes. For actions that aren't CRUD, a sub-resource noun usually reads better than a verb in the path, for example &lt;code&gt;POST /orders/42/cancellation&lt;/code&gt;. Don't fight over naming purity; the rule that matters is that the method's promised behavior is true.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Unbounded lists and offset pagination
&lt;/h2&gt;

&lt;p&gt;The first version of &lt;code&gt;GET /items&lt;/code&gt; returns everything. It works in development with 50 rows and takes the server down with 5 million. Always cap and paginate, even if you only have one client today.&lt;/p&gt;

&lt;p&gt;The second trap is the pagination style. Offset pagination (&lt;code&gt;?limit=3&amp;amp;offset=3&lt;/code&gt;) breaks when data changes between page requests. I fetched page one, deleted item 2, then fetched page two:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ curl -s "localhost:4040/items?limit=3&amp;amp;offset=0"
{"data":[{"id":1,"name":"item1"},{"id":2,"name":"item2"},{"id":3,"name":"item3"}]}
$ curl -s -X DELETE localhost:4040/items/2        # 204
$ curl -s "localhost:4040/items?limit=3&amp;amp;offset=3"
{"data":[{"id":5,"name":"item5"},{"id":6,"name":"item6"},{"id":7,"name":"item7"}]}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Item 4 never appeared. Deleting a row on an earlier page shifted everything up by one, and the next offset jumped over it. An insert does the opposite and shows a duplicate. Cursor (keyset) pagination asks for "the items after the last one I saw" and doesn't care what moved:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ curl -s "localhost:4040/items?limit=3&amp;amp;after=0"
{"data":[{"id":1,...},{"id":2,...},{"id":3,...}],"next_cursor":3}
$ curl -s -X DELETE localhost:4040/items/2        # 204
$ curl -s "localhost:4040/items?limit=3&amp;amp;after=3"
{"data":[{"id":4,"name":"item4"},{"id":5,"name":"item5"},{"id":6,"name":"item6"}],"next_cursor":6}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Same sequence, nothing skipped. (I shortened the first page's items with &lt;code&gt;...&lt;/code&gt; for width.) The Laravel documentation makes the same two points: offset pagination "may skip records or show duplicates" on data with frequent writes, and the &lt;code&gt;offset&lt;/code&gt; clause scans through all previously matched rows, so cursor pagination performs better on large tables when the ordering columns are indexed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Laravel: cursor pagination (the ordering must include a unique column)&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Order&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;query&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;orderBy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'id'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;cursorPaginate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The documented limits of cursor pagination: it only supports next/previous navigation, not "jump to page 40", and it requires ordering on at least one unique column, with no &lt;code&gt;null&lt;/code&gt; values in the ordering columns. If users truly need page numbers (an admin table, say), offset is fine; just know you are trading consistency for convenience. Also set a maximum page size on the server so &lt;code&gt;?limit=100000&lt;/code&gt; is not an option.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Retries that create duplicates
&lt;/h2&gt;

&lt;p&gt;A client sends &lt;code&gt;POST /orders&lt;/code&gt; and the connection drops before the response arrives. Did the order go through? The client can't know, so it retries, and now there may be two orders. Mobile networks, load balancers and impatient users make this routine, not rare. Without protection, the demo server does exactly what you fear:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ curl -s -X POST localhost:4040/orders -d '{"sku":"A1","qty":1}'
{"id":1,"sku":"A1","qty":1}  [201]
$ curl -s -X POST localhost:4040/orders -d '{"sku":"A1","qty":1}'
{"id":2,"sku":"A1","qty":1}  [201]
$ curl -s localhost:4040/orders
{"count":2}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The standard answer is an idempotency key: the client generates a unique value per logical operation and sends it with every retry, and the server remembers the result for that key. The IETF has an Internet-Draft for this, &lt;code&gt;draft-ietf-httpapi-idempotency-key-header&lt;/code&gt;. It is a draft, not an RFC; revision 08 was the latest when I checked, and details may still change. What it currently describes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The header is &lt;code&gt;Idempotency-Key&lt;/code&gt;, a structured-field String, and the draft recommends a UUID or similar random value.&lt;/li&gt;
&lt;li&gt;It targets non-idempotent methods, named as POST and PATCH.&lt;/li&gt;
&lt;li&gt;A request that reuses a key with a different payload should get &lt;code&gt;422&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;A retry that arrives while the first request is still processing should get &lt;code&gt;409&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;A missing key, for an operation that requires one, should get &lt;code&gt;400&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Expiry is left to the service, which should document its policy.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;My demo follows that behavior:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ curl -si -X POST localhost:4040/orders -H 'Idempotency-Key: "k-123"' -d '{"sku":"A1","qty":1}'
HTTP/1.1 201 Created
{"id":1,"sku":"A1","qty":1}
$ curl -si -X POST localhost:4040/orders -H 'Idempotency-Key: "k-123"' -d '{"sku":"A1","qty":1}'
HTTP/1.1 201 Created
Idempotent-Replayed: true
{"id":1,"sku":"A1","qty":1}
$ curl -s localhost:4040/orders
{"count":1}

$ curl -si -X POST localhost:4040/orders -H 'Idempotency-Key: "k-123"' -d '{"sku":"B2","qty":5}'
HTTP/1.1 422 Unprocessable Entity
Content-Type: application/problem+json

{"type":"about:blank","title":"Idempotency key reused with a different payload","status":422}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(&lt;code&gt;Idempotent-Replayed&lt;/code&gt; is my own demo header, not part of the draft.) The retry returned the original order and the count stayed at one. A real implementation needs more than my in-memory map:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Store the key, a hash of the request body, and the response in the database, with a &lt;strong&gt;unique constraint&lt;/strong&gt; on the key (scoped to the user or API client, so one customer can't collide with another).&lt;/li&gt;
&lt;li&gt;Insert the key &lt;em&gt;before&lt;/em&gt; doing the work, so two simultaneous retries can't both pass the check. The loser gets the &lt;code&gt;409&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Write the key and the business change in the same transaction, or you can record a key for work that rolled back.&lt;/li&gt;
&lt;li&gt;Expire old keys on a schedule you document.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I did not write a Laravel implementation for this article, so there is no copy-paste middleware here; the four rules above are the part that makes it correct, and the storage can be a plain table.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Breaking changes with no warning
&lt;/h2&gt;

&lt;p&gt;Clients you don't control (mobile apps in particular) can't be updated the day you ship. What counts as breaking is mostly a matter of reasoning about what a client has to assume. Adding a new optional response field or a new endpoint is normally safe, as long as clients ignore unknown fields. Removing or renaming a field, changing its type (a number to a string, an object to an array), tightening validation, or changing what a status code means will break someone.&lt;/p&gt;

&lt;p&gt;When you must break something, say so in the response itself. Two standards cover this. RFC 9745 defines a &lt;code&gt;Deprecation&lt;/code&gt; response header whose value is a date written as a structured-field Date, for example &lt;code&gt;@1688169599&lt;/code&gt;, and it can be in the past (already deprecated) or the future (planned). The older RFC 8594 defines &lt;code&gt;Sunset&lt;/code&gt;, the time the resource is expected to stop responding, and RFC 9745 says the Sunset time must not be earlier than the Deprecation date. A &lt;code&gt;Link&lt;/code&gt; header with &lt;code&gt;rel="deprecation"&lt;/code&gt; points to the migration documentation. A response from the demo:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ curl -si localhost:4042/v1/report
HTTP/1.1 200 OK
Deprecation: @1788912000
Sunset: Thu, 30 Sep 2027 23:59:59 GMT
Link: &amp;lt;https://api.example.com/docs/migrate-v2&amp;gt;; rel="deprecation"; type="text/html"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note the two date formats: &lt;code&gt;Deprecation&lt;/code&gt; is a Unix timestamp prefixed with &lt;code&gt;@&lt;/code&gt; (here 1788912000 is 9 September 2026, 00:00 UTC), while &lt;code&gt;Sunset&lt;/code&gt; uses the classic HTTP date. RFC 9745 itself points out that they differ for historical reasons. I got the weekday wrong on my first draft of that header, which is a good reason to generate these values with code instead of typing them.&lt;/p&gt;

&lt;p&gt;The headers only help if someone reads them. Log which clients still call deprecated endpoints (by API key or user agent) so you can contact them before the sunset date, and keep the old version running until the numbers say it is safe. How you expose versions (a &lt;code&gt;/v1/&lt;/code&gt; path prefix, a header, a media type) is a trade-off with no universally right answer; a path prefix is the simplest to route, cache and debug, so it is a reasonable default.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. No object-level authorization
&lt;/h2&gt;

&lt;p&gt;Authentication tells you who is calling. Authorization has to check, on &lt;em&gt;every request for a specific object&lt;/em&gt;, whether this caller may touch it. The classic mistake is checking only that the token is valid, then loading &lt;code&gt;/orders/{id}&lt;/code&gt; for whatever ID the client sent. This is Broken Object Level Authorization, and it is API1 in the OWASP API Security Top 10 (2023 edition). In the demo, Ann's token reads Bob's order:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ curl -s -H 'Authorization: Bearer tok-ann' localhost:4041/bad/orders/11
{"id":11,"owner":2,"total":9900} [200]

$ curl -s -H 'Authorization: Bearer tok-ann' localhost:4041/good/orders/11
{"title":"Not found"} [404]

$ curl -s -H 'Authorization: Bearer tok-ann' localhost:4041/good/orders/999
{"title":"Not found"} [404]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The fixed version returns the same &lt;code&gt;404&lt;/code&gt; for "exists but isn't yours" and "doesn't exist", so the response doesn't confirm which IDs are real. Whether to use 404 or 403 is a design decision: 403 is more honest and easier to debug but tells an attacker the object exists; 404 hides that. Pick one on purpose and apply it consistently.&lt;/p&gt;

&lt;p&gt;Using sequential integer IDs makes the bug easy to exploit, because the attacker just counts upward, but switching to UUIDs doesn't fix the missing check; it only makes guessing harder. The fix is the check, and the cheapest way to make it hard to forget is to query through the owner:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Scope the lookup to the authenticated user; a foreign id behaves like a missing one&lt;/span&gt;
&lt;span class="nv"&gt;$order&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;user&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;orders&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;findOrFail&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Or, if you prefer explicit policies (this returns 403 on denial):&lt;/span&gt;
&lt;span class="nv"&gt;$order&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Order&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;findOrFail&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;authorize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'view'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$order&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The same applies to functions, not only objects: an endpoint like &lt;code&gt;DELETE /admin/users/5&lt;/code&gt; needs its own role check (OWASP lists that as API5, Broken Function Level Authorization). For a wider checklist of what to lock down in a Laravel app.&lt;/p&gt;

&lt;h2&gt;
  
  
  8. Exposing and accepting whole models
&lt;/h2&gt;

&lt;p&gt;Two mirror-image mistakes share one cause: the API shape is whatever the database model happens to look like.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;On the way out&lt;/strong&gt;, returning the model directly leaks columns nobody meant to publish. In the demo, &lt;code&gt;GET /bad/me&lt;/code&gt; serializes the whole user record:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ curl -s -H 'Authorization: Bearer tok-ann' localhost:4041/bad/me
{"id":1,"name":"Ann","email":"ann@example.test","is_admin":false,"password_hash":"$2y$secret"}

$ curl -s -H 'Authorization: Bearer tok-ann' localhost:4041/good/me
{"id":1,"name":"Ann","email":"ann@example.test"}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;On the way in&lt;/strong&gt;, copying the request body onto the model is mass assignment. Ann sends one extra field:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ curl -s -X PATCH -H 'Authorization: Bearer tok-ann' -d '{"name":"Ann","is_admin":true}' localhost:4041/good/me
{"ok":true,"is_admin":false}

$ curl -s -X PATCH -H 'Authorization: Bearer tok-ann' -d '{"name":"Ann","is_admin":true}' localhost:4041/bad/me
{"ok":true,"is_admin":true}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On the unsafe endpoint she promoted herself to admin. OWASP groups both under API3:2023, Broken Object Property Level Authorization. The fix is the same in both directions: write the shape down. In Laravel that means a Form Request with explicit rules, using only &lt;code&gt;validated()&lt;/code&gt; input, and an API Resource for output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// app/Http/Requests/UpdateProfileRequest.php&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;UpdateProfileRequest&lt;/span&gt; &lt;span class="k"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;FormRequest&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;rules&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;array&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="s1"&gt;'name'&lt;/span&gt;  &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'sometimes'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'string'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'max:100'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="s1"&gt;'email'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'sometimes'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'email'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'max:255'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// app/Http/Resources/UserResource.php&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;UserResource&lt;/span&gt; &lt;span class="k"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;JsonResource&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;toArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Request&lt;/span&gt; &lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;array&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="s1"&gt;'id'&lt;/span&gt;    &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="s1"&gt;'name'&lt;/span&gt;  &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="s1"&gt;'email'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// controller&lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;UpdateProfileRequest&lt;/span&gt; &lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;user&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;validated&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;UserResource&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;user&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;refresh&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because &lt;code&gt;validated()&lt;/code&gt; returns only the keys that have rules, an &lt;code&gt;is_admin&lt;/code&gt; field in the body is dropped rather than saved. Treat the model's &lt;code&gt;$fillable&lt;/code&gt; list as a second line of defense, not the first. The explicit resource also gives you a stable contract: adding a column to the table doesn't silently add a field to the public API.&lt;/p&gt;

&lt;h2&gt;
  
  
  9. No rate limiting
&lt;/h2&gt;

&lt;p&gt;Without limits, one buggy client in a retry loop, one scraper or one credential-stuffing script can eat the capacity every other user shares. OWASP calls the general problem Unrestricted Resource Consumption (API4:2023). Limits also protect your database and your bill.&lt;/p&gt;

&lt;p&gt;RFC 6585 defines &lt;code&gt;429 Too Many Requests&lt;/code&gt;: the client sent too many requests in a given time. The response should describe the problem and may include a &lt;code&gt;Retry-After&lt;/code&gt; header saying how long to wait. Giving well-behaved clients a number is what turns a limit from a wall into a protocol:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ for i in 1 2 3 4; do curl -s -o /dev/null -w "req $i -&amp;gt; %{http_code}\n" localhost:4042/search; done
req 1 -&amp;gt; 200
req 2 -&amp;gt; 200
req 3 -&amp;gt; 200
req 4 -&amp;gt; 429

$ curl -si localhost:4042/search
HTTP/1.1 429 Too Many Requests
Content-Type: application/problem+json
Retry-After: 30

{"title":"Too Many Requests","status":429,"detail":"Limit is 3 requests per minute."}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In Laravel, define a named limiter and attach it with the &lt;code&gt;throttle&lt;/code&gt; middleware. This is the example from the framework documentation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// app/Providers/AppServiceProvider.php, in boot()&lt;/span&gt;
&lt;span class="nc"&gt;RateLimiter&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'api'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Request&lt;/span&gt; &lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Limit&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;perMinute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;by&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;user&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="o"&gt;?:&lt;/span&gt; &lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;ip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The docs state that Laravel returns a 429 automatically when the limit is exceeded, but they don't list which headers it sends, so run &lt;code&gt;curl -i&lt;/code&gt; against your own app and confirm that &lt;code&gt;Retry-After&lt;/code&gt; is present before you tell client developers they can rely on it. Think about what you key the limit on: per-IP limits punish everyone behind one office or mobile carrier address, while per-user limits don't stop anonymous floods, so most APIs need both. Stricter limits belong on login and password-reset endpoints, and the limit counters should live in a shared store like Redis when you run more than one server, otherwise each server counts separately.&lt;/p&gt;

&lt;h2&gt;
  
  
  10. Sloppy data conventions: money, dates and naming
&lt;/h2&gt;

&lt;p&gt;These are small decisions that are very hard to change later.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Money as floating point.&lt;/strong&gt; JSON numbers are doubles in many clients, and binary floating point can't represent most decimal amounts exactly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ node -e 'console.log(19.99*100); console.log(Math.round(19.99*100))'
1998.9999999999998
1999

$ php -r 'var_dump((int)(19.99*100));'
int(1998)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That PHP line is the dangerous one: a cast truncates, and a customer is charged 1998 cents instead of 1999. Send money as an integer in the smallest currency unit plus an explicit currency, &lt;code&gt;{"amount": 1999, "currency": "USD"}&lt;/code&gt;, or as a decimal &lt;em&gt;string&lt;/em&gt; (&lt;code&gt;"19.99"&lt;/code&gt;) that the client parses with a decimal library. Be careful with currencies that don't have two minor digits; this is why the currency should travel with the amount.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dates without a time zone.&lt;/strong&gt; &lt;code&gt;"2026-11-09 22:03"&lt;/code&gt; means nothing without an offset. Use RFC 3339 / ISO 8601 timestamps with an explicit offset or &lt;code&gt;Z&lt;/code&gt;, and store UTC. The same instant in both forms, from Node:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2026-11-09T22:03:00+05:30      (what the user saw in Colombo)
2026-11-09T16:33:00.000Z       (the same instant in UTC)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Mixed naming.&lt;/strong&gt; &lt;code&gt;userId&lt;/code&gt; in one response, &lt;code&gt;user_id&lt;/code&gt; in another, &lt;code&gt;UserID&lt;/code&gt; in a third. Pick one convention (snake_case or camelCase), and apply it to field names, query parameters and error members alike. Same for booleans (&lt;code&gt;is_active&lt;/code&gt; everywhere, not &lt;code&gt;active&lt;/code&gt; here and &lt;code&gt;enabled&lt;/code&gt; there), plural collection names, and ID types. A lint step in CI over your OpenAPI file will catch most drift, and having that file at all is the other half of this mistake: an API without a machine-readable description gets documented by whoever last read the code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Related Dev Talk articles
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://dev-talk.com/post/postgresql-vs-mysql-performance-comparison" rel="noopener noreferrer"&gt;PostgreSQL vs MySQL: Performance Comparison&lt;/a&gt; (for choosing the store behind your keyset pagination and idempotency table)&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://dev-talk.com/post/common-api-design-mistakes" rel="noopener noreferrer"&gt;DEV Talk&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>apidesign</category>
      <category>restapi</category>
      <category>httpstatuscodes</category>
      <category>pagination</category>
    </item>
    <item>
      <title>Git Merge vs Rebase: Practical Examples and When to Use Each</title>
      <dc:creator>devTalk</dc:creator>
      <pubDate>Fri, 13 Nov 2026 15:13:58 +0000</pubDate>
      <link>https://dev.to/devtalk94/git-merge-vs-rebase-practical-examples-and-when-to-use-each-339</link>
      <guid>https://dev.to/devtalk94/git-merge-vs-rebase-practical-examples-and-when-to-use-each-339</guid>
      <description>&lt;p&gt;&lt;em&gt;Last updated: 9 November 2026. See the&lt;/em&gt;&lt;em&gt;update log&lt;/em&gt;&lt;em&gt;at the end.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;You branched off &lt;code&gt;main&lt;/code&gt;, did some work, and now &lt;code&gt;main&lt;/code&gt; has moved on. Git offers two ways to bring the branches back together, &lt;code&gt;git merge&lt;/code&gt; and &lt;code&gt;git rebase&lt;/code&gt;, and both end with the same files on disk. What differs is the history you leave behind, how many conflicts you resolve, and what happens to your teammates if the branch is shared. Pick wrongly and you get either a tangle of merge commits or a force-push that wrecks someone's afternoon.&lt;/p&gt;

&lt;p&gt;This article runs both on the same repository, side by side, with the real commands and output, then covers the situations where the choice matters: conflicts, shared branches, squash merges, pulling, and undoing a mistake. All of it was run on Git 2.43.0.&lt;/p&gt;

&lt;h2&gt;
  
  
  The short answer
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Merge&lt;/th&gt;
&lt;th&gt;Rebase&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;What it does&lt;/td&gt;
&lt;td&gt;Adds one new commit with two parents that joins the histories&lt;/td&gt;
&lt;td&gt;Replays your commits one by one on top of the new base, creating &lt;em&gt;new&lt;/em&gt; commits&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;History afterwards&lt;/td&gt;
&lt;td&gt;Branches and joins stay visible&lt;/td&gt;
&lt;td&gt;One straight line&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Your existing commits&lt;/td&gt;
&lt;td&gt;Untouched, same SHAs&lt;/td&gt;
&lt;td&gt;Replaced, new SHAs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Conflicts&lt;/td&gt;
&lt;td&gt;Resolved once, in the merge commit&lt;/td&gt;
&lt;td&gt;Can appear once per replayed commit&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Safe on a branch others use&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;No, unless everyone agrees&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Undo&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;reset&lt;/code&gt; before pushing; &lt;code&gt;revert -m 1&lt;/code&gt; after&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;reset --hard ORIG_HEAD&lt;/code&gt; or the reflog&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;My rule of thumb, as a practical recommendation rather than a law: rebase your own unpublished work to keep it tidy, merge anything that other people already have. The sections below show why.&lt;/p&gt;

&lt;h2&gt;
  
  
  The starting point
&lt;/h2&gt;

&lt;p&gt;A small repository. &lt;code&gt;main&lt;/code&gt; has two commits. &lt;code&gt;feature/search&lt;/code&gt; was branched from the second one and has two commits of its own. Meanwhile someone added a third commit to &lt;code&gt;main&lt;/code&gt;, so the histories have diverged:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git log --oneline --graph --decorate --all
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;* cb7fefb (HEAD -&amp;gt; main) Update README
| * ad97d89 (feature/search) Add search filters
| * 1625bc4 Add search index
|/
* 61382cb Add app skeleton
* db814b5 Initial commit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Merge: keep the history exactly as it happened
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git switch main
git merge feature/search
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Merge made by the 'ort' strategy.
 search.txt | 2 ++
 1 file changed, 2 insertions(+)
 create mode 100644 search.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;*   a3e6b0f (HEAD -&amp;gt; main) Merge branch 'feature/search'
|\
| * ad97d89 (feature/search) Add search filters
| * 1625bc4 Add search index
* | cb7fefb Update README
|/
* 61382cb Add app skeleton
* db814b5 Initial commit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Nothing was rewritten. &lt;code&gt;ad97d89&lt;/code&gt; and &lt;code&gt;1625bc4&lt;/code&gt; kept their SHAs, and a new merge commit &lt;code&gt;a3e6b0f&lt;/code&gt; records that the two lines of work joined. The graph is honest, but it gets busy on a team that merges many branches a day. One tool helps: &lt;code&gt;--first-parent&lt;/code&gt; follows only the main line and hides the commits inside each merged branch:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git log --oneline --first-parent
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a3e6b0f Merge branch 'feature/search'
cb7fefb Update README
61382cb Add app skeleton
db814b5 Initial commit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That gives you a readable "one line per feature" view of &lt;code&gt;main&lt;/code&gt; without rewriting anything.&lt;/p&gt;

&lt;h2&gt;
  
  
  Rebase: replay your commits on top of main
&lt;/h2&gt;

&lt;p&gt;Same starting point, different command. Run it on the &lt;em&gt;feature&lt;/em&gt; branch:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git switch feature/search
git rebase main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Successfully rebased and updated refs/heads/feature/search.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(While it works, Git also prints a progress line such as &lt;code&gt;Rebasing (2/2)&lt;/code&gt;.) Compare the two commits before and after:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;before:                  after:
ad97d89 Add search filters       cb365e1 Add search filters
1625bc4 Add search index         9a325d7 Add search index
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;* cb365e1 (HEAD -&amp;gt; feature/search) Add search filters
* 9a325d7 Add search index
* cb7fefb (main) Update README
* 61382cb Add app skeleton
* db814b5 Initial commit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The commit messages and changes are the same, but the SHAs are different. A commit's SHA includes its parent, and the parent changed, so Git created new commits and moved the branch label to them. The old commits still exist (more on that in the undo section). The history is now a single line, and merging into &lt;code&gt;main&lt;/code&gt; becomes a fast-forward with no merge commit:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git switch main
git merge feature/search
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Updating cb7fefb..cb365e1
Fast-forward
 search.txt | 2 ++
 1 file changed, 2 insertions(+)
 create mode 100644 search.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you want Git to refuse anything that is not a clean fast-forward, add &lt;code&gt;--ff-only&lt;/code&gt;. On the diverged branches from the start of this article it stops and tells you what to do:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git merge --ff-only feature/search
hint: Diverging branches can't be fast-forwarded, you need to either:
hint:
hint:   git merge --no-ff
hint:
hint: or:
hint:
hint:   git rebase
hint:
hint: Disable this message with "git config advice.diverging false"
fatal: Not possible to fast-forward, aborting.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Fast-forward vs --no-ff, when nothing has diverged
&lt;/h2&gt;

&lt;p&gt;If &lt;code&gt;main&lt;/code&gt; has not moved, a merge does not need a merge commit. Git just slides the branch pointer forward:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git merge feature/login
Updating 61382cb..e6c3f9a
Fast-forward
 login.txt | 2 ++
 1 file changed, 2 insertions(+)
 create mode 100644 login.txt

* e6c3f9a (HEAD -&amp;gt; main, feature/login) Add login validation
* 0745ccd Add login form
* 61382cb Add app skeleton
* db814b5 Initial commit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The result is linear, and afterwards nobody can tell a branch ever existed. If you want to keep a visible record of the feature as a unit, force a merge commit with &lt;code&gt;--no-ff&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git merge --no-ff -m "Merge feature/login" feature/login
Merge made by the 'ort' strategy.

*   767bc44 (HEAD -&amp;gt; main) Merge feature/login
|\
| * e6c3f9a (feature/login) Add login validation
| * 0745ccd Add login form
|/
* 61382cb Add app skeleton
* db814b5 Initial commit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Keeping a feature branch up to date
&lt;/h2&gt;

&lt;p&gt;The most common daily use: &lt;code&gt;main&lt;/code&gt; moved, and you want its changes in your branch. Merging &lt;code&gt;main&lt;/code&gt; into the feature branch works, but adds a merge commit every time you do it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git merge main
Merge made by the 'ort' strategy.

*   eeec354 (HEAD -&amp;gt; feature/search) Merge branch 'main' into feature/search
|\
| * cb7fefb (main) Update README
* | ad97d89 Add search filters
* | 1625bc4 Add search index
|/
* 61382cb Add app skeleton
* db814b5 Initial commit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Rebasing onto &lt;code&gt;main&lt;/code&gt; instead (as in the earlier section) keeps the branch a clean series of commits on top of the latest &lt;code&gt;main&lt;/code&gt;, which makes the pull request easier to review. The cost is that you must not do it once other people have based work on your branch.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conflicts: where the two really differ
&lt;/h2&gt;

&lt;p&gt;A merge brings both branches together in one step, so you resolve each conflicting area once. A rebase replays your commits one at a time, so if several of your commits touch the same lines, you may resolve them repeatedly. I set up a conflict deliberately: &lt;code&gt;main&lt;/code&gt; changed &lt;code&gt;timeout=30&lt;/code&gt; to &lt;code&gt;timeout=60&lt;/code&gt;, while the feature branch has two commits, the first setting it to 45 and the second setting 50 and adding a &lt;code&gt;retries&lt;/code&gt; line.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;* e62c282 (HEAD -&amp;gt; main) Raise timeout to 60
| * 91af4b7 (feature/timeout) Tune timeout and add retries
| * cba3fc7 Tune timeout for slow API
|/
* 1b8f2a7 Initial commit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Merge: one conflict
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git merge feature/timeout
Auto-merging config.txt
CONFLICT (content): Merge conflict in config.txt
Automatic merge failed; fix conflicts and then commit the result.

$ cat config.txt
&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; HEAD
timeout=60
=======
timeout=50
retries=3
&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; feature/timeout

$ git status --short
UU config.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I resolved it to &lt;code&gt;timeout=60&lt;/code&gt; plus &lt;code&gt;retries=3&lt;/code&gt;, committed, and was done: one resolution, and the graph shows the join.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;*   82da93a (HEAD -&amp;gt; main) Merge branch 'feature/timeout'
|\
| * 91af4b7 (feature/timeout) Tune timeout and add retries
| * cba3fc7 Tune timeout for slow API
* | e62c282 Raise timeout to 60
|/
* 1b8f2a7 Initial commit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Rebase: a conflict for each commit that collides
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git rebase main
Auto-merging config.txt
CONFLICT (content): Merge conflict in config.txt
error: could not apply cba3fc7... Tune timeout for slow API
Could not apply cba3fc7... Tune timeout for slow API

$ cat config.txt
&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; HEAD
timeout=60
=======
timeout=45
&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; cba3fc7 (Tune timeout for slow API)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(I trimmed Git's &lt;code&gt;hint:&lt;/code&gt; lines throughout.) Here &lt;code&gt;HEAD&lt;/code&gt; is the new base, &lt;code&gt;main&lt;/code&gt;, and the other side is the single commit being replayed. I resolved it to &lt;code&gt;timeout=60&lt;/code&gt;, ran &lt;code&gt;git add config.txt&lt;/code&gt; and &lt;code&gt;git rebase --continue&lt;/code&gt;, and Git moved on to the second commit, which collided as well:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git rebase --continue
Auto-merging config.txt
CONFLICT (content): Merge conflict in config.txt
error: could not apply 91af4b7... Tune timeout and add retries
Could not apply 91af4b7... Tune timeout and add retries

$ cat config.txt
&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; HEAD
timeout=60
=======
timeout=50
retries=3
&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; 91af4b7 (Tune timeout and add retries)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Second resolution: &lt;code&gt;timeout=60&lt;/code&gt; plus &lt;code&gt;retries=3&lt;/code&gt;, then &lt;code&gt;git rebase --continue&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[detached HEAD 8fc3ae3] Tune timeout and add retries
 1 file changed, 1 insertion(+)
Successfully rebased and updated refs/heads/feature/timeout.

* 8fc3ae3 (HEAD -&amp;gt; feature/timeout) Tune timeout and add retries
* e62c282 (main) Raise timeout to 60
* 1b8f2a7 Initial commit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two things to notice. First, the two conflicts: the merge asked once, the rebase asked twice. Second, the branch ended with &lt;em&gt;one&lt;/em&gt; commit, not two. My first resolution (&lt;code&gt;timeout=60&lt;/code&gt;) matched what &lt;code&gt;main&lt;/code&gt; already had, so the first commit became empty and Git dropped it without a message. That is correct behavior, but it surprises people who expect every commit to survive.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cutting down repeated conflicts: squash first
&lt;/h3&gt;

&lt;p&gt;If your branch has several small commits that keep colliding, squash them into one before rebasing, so you resolve once. This does throw away the individual commit history, which is the trade-off:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git reset --soft &lt;span class="nv"&gt;$(&lt;/span&gt;git merge-base main feature/timeout&lt;span class="o"&gt;)&lt;/span&gt;
git commit -m &lt;span class="s2"&gt;"Tune timeout and add retries"&lt;/span&gt;
git rebase main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;* d3d35ff (HEAD -&amp;gt; feature/timeout) Tune timeout and add retries
| * e62c282 (main) Raise timeout to 60
|/
* 1b8f2a7 Initial commit
Auto-merging config.txt
CONFLICT (content): Merge conflict in config.txt
error: could not apply d3d35ff... Tune timeout and add retries
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One commit, one conflict. For picking which commits to combine more precisely, use &lt;code&gt;git rebase -i&lt;/code&gt; (covered in the &lt;a href="https://dev-talk.com/blog/git-rebase-rewriting-history-safely" rel="noopener noreferrer"&gt;rebase part of this Git series&lt;/a&gt;).&lt;/p&gt;

&lt;h3&gt;
  
  
  Bailing out of either one
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git merge --abort
git rebase --abort
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both put the branch back as it was before you started. After &lt;code&gt;git rebase --abort&lt;/code&gt; in my test the status was &lt;code&gt;nothing to commit, working tree clean&lt;/code&gt; and the graph showed the original &lt;code&gt;91af4b7&lt;/code&gt; and &lt;code&gt;cba3fc7&lt;/code&gt; commits again.&lt;/p&gt;

&lt;h2&gt;
  
  
  Rebase refuses to run on a dirty working tree
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git rebase main
error: cannot rebase: You have unstaged changes.
error: Please commit or stash them.

$ git rebase --autostash main
Created autostash: 44ed3df
Applied autostash.
Successfully rebased and updated refs/heads/feature/search.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;--autostash&lt;/code&gt; stashes your uncommitted changes, rebases, and reapplies them. If the reapply conflicts, Git keeps the stash for you. For the manual version, see the &lt;a href="https://dev-talk.com/blog/git-stash-cherry-pick-worktrees" rel="noopener noreferrer"&gt;stash part of this series&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The golden rule: don't rewrite commits other people have
&lt;/h2&gt;

&lt;p&gt;Rebase creates new commits to replace old ones. On your own local branch that is harmless. On a branch that a teammate has already pulled, it leaves their copy of the old commits stranded. I simulated that with a bare remote and two clones. Alice and Bob both have &lt;code&gt;feature/search&lt;/code&gt;. Alice rebases it onto an updated &lt;code&gt;main&lt;/code&gt; and tries to push:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git push
 ! [rejected]        feature/search -&amp;gt; feature/search (non-fast-forward)
error: failed to push some refs to '…'
hint: Updates were rejected because the tip of your current branch is behind

$ git push --force-with-lease
 + 871afc9...731f5a1 feature/search -&amp;gt; feature/search (forced update)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(I replaced the repository path with &lt;code&gt;…&lt;/code&gt;.) The plain push is rejected because the rewritten branch is no longer a descendant of what is on the remote. &lt;code&gt;--force-with-lease&lt;/code&gt; overwrites it. Bob still has the old commits and adds one of his own:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;* 6db2161 (HEAD -&amp;gt; feature/search) Add search sorting
* 871afc9 (origin/feature/search) Add search filters
* 7ed4e8b Add search index
* db814b5 (origin/main, origin/HEAD, main) Initial commit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now Bob runs a plain merge-style pull, and gets a conflict in a file he never touched:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git pull --no-rebase
Auto-merging search.txt
CONFLICT (add/add): Merge conflict in search.txt
Automatic merge failed; fix conflicts and then commit the result.

$ git status --short
M  README.md
AA search.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;AA&lt;/code&gt; means both sides added &lt;code&gt;search.txt&lt;/code&gt;: Alice's rewritten commits created it, and so did Bob's old ones, as unrelated commits to Git. After &lt;code&gt;git merge --abort&lt;/code&gt;, Bob can recover with &lt;code&gt;git pull --rebase&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git pull --rebase
Successfully rebased and updated refs/heads/feature/search.

* 5474049 (HEAD -&amp;gt; feature/search) Add search sorting
* 731f5a1 (origin/feature/search) Add search filters
* 769bcce Add search index
* bf92bdd (origin/main, origin/HEAD) Update README
* db814b5 (main) Initial commit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here Git recognized that Bob's two old commits were already upstream in rewritten form and dropped them, keeping only &lt;code&gt;Add search sorting&lt;/code&gt;. That worked because Alice's rebase did not change the contents of her commits. If she had also edited or conflict-resolved them, the recovery would be harder. Do not rely on it as a plan.&lt;/p&gt;

&lt;h3&gt;
  
  
  Always --force-with-lease, never --force
&lt;/h3&gt;

&lt;p&gt;In a second run, Alice rebased locally, then Bob pushed a new commit to the same branch before Alice pushed. Alice had not fetched his commit:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git push --force-with-lease
 ! [rejected]        feature/search -&amp;gt; feature/search (stale info)

$ git push --force
 + 811a4ba...3265a02 feature/search -&amp;gt; feature/search (forced update)

$ git log --oneline feature/search      # on the remote, afterwards
3265a02 Add search index
36bce11 Update README
d8f1998 Initial commit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The lease refused, because the remote had moved since Alice last looked ("stale info"). The plain force overwrote it, and Bob's commit &lt;code&gt;Add search sorting&lt;/code&gt; is gone from the remote. The lease costs nothing, and it is the difference between an annoying rejection and lost work. The &lt;a href="https://dev-talk.com/blog/git-rebase-rewriting-history-safely" rel="noopener noreferrer"&gt;rebase part of the series&lt;/a&gt; covers pushing after a rebase in more depth.&lt;/p&gt;

&lt;h2&gt;
  
  
  Squash merge: one commit per branch
&lt;/h2&gt;

&lt;p&gt;Many teams squash a branch into a single commit when merging a pull request. Locally that is &lt;code&gt;git merge --squash&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git merge --squash feature/search
Automatic merge went well; stopped before committing as requested
Squash commit -- not updating HEAD

$ git commit -m "Add search (squashed)"

* ad97d89 (feature/search) Add search filters
* 1625bc4 Add search index
| * 902732e (HEAD -&amp;gt; main) Add search (squashed)
| * cb7fefb Update README
|/
* 61382cb Add app skeleton
* db814b5 Initial commit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The result on &lt;code&gt;main&lt;/code&gt; is one new commit, and the feature branch is not connected to it in the graph. That has a practical consequence, because Git no longer knows the branch was merged:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git branch --merged main
* main

$ git branch -d feature/search
error: the branch 'feature/search' is not fully merged.
If you are sure you want to delete it, run 'git branch -D feature/search'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Only delete such a branch with &lt;code&gt;-D&lt;/code&gt; after checking that the squash commit contains everything. Also avoid continuing work on a branch after it has been squash-merged, since its old commits will conflict with the squashed copy. The GitHub documentation says the same: "Squash merging works best for short-lived branches."&lt;/p&gt;

&lt;p&gt;GitHub's pull request button offers all three strategies from this article, as documented: create a merge commit (a &lt;code&gt;--no-ff&lt;/code&gt; merge that keeps all the branch's commits), squash and merge, and rebase and merge. For rebase and merge, GitHub's page states that it "always updates the committer information and creates new commit SHAs", so commits on &lt;code&gt;main&lt;/code&gt; will not match the SHAs on your local branch. I did not test GitHub itself.&lt;/p&gt;

&lt;h2&gt;
  
  
  Rebasing a branch that contains merges
&lt;/h2&gt;

&lt;p&gt;A plain &lt;code&gt;git rebase&lt;/code&gt; flattens merge commits. Here &lt;code&gt;feature/cart&lt;/code&gt; contains a merge of a smaller branch (&lt;code&gt;feature/cart-coupons&lt;/code&gt;), and &lt;code&gt;main&lt;/code&gt; has moved on:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;*   4892d20 (HEAD -&amp;gt; feature/cart) Merge coupons into cart
|\
| * b575b69 (feature/cart-coupons) Add coupon codes
* | c934647 Add cart total
|/
* 31aa099 Add cart list
* db814b5 Initial commit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git rebase main
Successfully rebased and updated refs/heads/feature/cart.
* ff2d7ef (HEAD -&amp;gt; feature/cart) Add coupon codes
* 6a3df45 Add cart total
* 5b818cf Add cart list
* c5906fe (main) Update README
* db814b5 Initial commit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The merge commit disappeared and the structure of the work was flattened. If you want to keep it, use &lt;code&gt;--rebase-merges&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git rebase --rebase-merges main
Successfully rebased and updated refs/heads/feature/cart.

*   8a9845e (HEAD -&amp;gt; feature/cart) Merge coupons into cart
|\
| * 1dd0e01 Add coupon codes
* | 6a3df45 Add cart total
|/
* 5b818cf Add cart list
* c5906fe (main) Update README
* db814b5 Initial commit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note that &lt;code&gt;feature/cart-coupons&lt;/code&gt; itself still points at its old commit in both cases; a rebase moves only the branch you are on.&lt;/p&gt;

&lt;h2&gt;
  
  
  Undoing each one
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;A merge you have not pushed.&lt;/strong&gt; Git saves the previous tip as &lt;code&gt;ORIG_HEAD&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git reset --hard ORIG_HEAD
HEAD is now at cb7fefb Update README
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;A rebase you have not pushed.&lt;/strong&gt; Same trick, and the old commits come back with their old SHAs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;before:        ad97d89 Add search filters / 1625bc4 Add search index
after rebase: 6976b4e Add search filters / f18a57b Add search index

$ git reset --hard ORIG_HEAD
HEAD is now at ad97d89 Add search filters
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(The rebased SHAs differ from the earlier rebase example because this was a separate test run; the point is that they change.) &lt;code&gt;ORIG_HEAD&lt;/code&gt; is overwritten by the next merge, reset or rebase, so if you have done anything since, use &lt;code&gt;git reflog&lt;/code&gt;. The &lt;a href="https://dev-talk.com/blog/git-undo-mistakes-reset-revert-reflog" rel="noopener noreferrer"&gt;undo part of the series&lt;/a&gt; covers that.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A merge that is already pushed.&lt;/strong&gt; You cannot rewrite shared history, so you add a commit that reverses it. A merge commit has two parents, so you must tell Git which side to keep with &lt;code&gt;-m 1&lt;/code&gt; (the first parent, normally &lt;code&gt;main&lt;/code&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git revert -m 1 HEAD
[main 1b63300] Revert "Merge branch 'feature/search'"
 Date: Thu Jan 1 00:01:00 2026 +0000
 1 file changed, 2 deletions(-)
$ ls
README.md
app.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The feature's changes are gone from the working tree. Now the trap: when the fixed branch is ready and you merge it again, Git thinks it is already merged.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git merge feature/search
Already up to date.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The original merge still counts as having included those commits. To get the changes back, revert the revert:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git revert --no-edit 1b63300
[main f224762] Reapply "Merge branch 'feature/search'"
 Date: Thu Jan 1 00:02:00 2026 +0000
$ ls
README.md
app.txt
search.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or merge a new branch that includes your fixes as new commits on top of the old ones. Either way, know about this behavior before the day you need it.&lt;/p&gt;

&lt;h2&gt;
  
  
  What git pull does: pick a default
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;git pull&lt;/code&gt; is a fetch followed by a merge or a rebase, and Git 2.43 will not pick for you when the branches have diverged:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git pull
hint: You have divergent branches and need to specify how to reconcile them.
hint: You can do so by running one of the following commands sometime before
hint: your next pull:
hint:
hint:   git config pull.rebase false  # merge
hint:   git config pull.rebase true   # rebase
hint:   git config pull.ff only       # fast-forward only
fatal: Need to specify how to reconcile divergent branches.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git pull --ff-only
fatal: Not possible to fast-forward, aborting.
$ git pull --rebase
Successfully rebased and updated refs/heads/main.
* 47f354b (HEAD -&amp;gt; main) Bob: add notes
* ddd4bcf (origin/main, origin/HEAD) Alice: add app
* db814b5 Initial commit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Set one default and stop thinking about it. &lt;code&gt;pull.rebase true&lt;/code&gt; keeps your local, unpushed commits on top of the remote ones, which is safe because those are the only commits being rewritten. &lt;code&gt;pull.ff only&lt;/code&gt; makes a diverged pull stop and ask, which is the most cautious. Use &lt;code&gt;git config --global&lt;/code&gt; to apply either to every repository.&lt;/p&gt;

&lt;h2&gt;
  
  
  Which should you use?
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Situation&lt;/th&gt;
&lt;th&gt;Use&lt;/th&gt;
&lt;th&gt;Why&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Your own unpushed branch is behind &lt;code&gt;main&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Rebase&lt;/td&gt;
&lt;td&gt;Clean history, nobody affected&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A branch you pushed, only you use it&lt;/td&gt;
&lt;td&gt;Rebase, then &lt;code&gt;--force-with-lease&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Safe if you are the only one; the lease checks it&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A branch shared with teammates&lt;/td&gt;
&lt;td&gt;Merge&lt;/td&gt;
&lt;td&gt;Rewriting strands their copies&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;main&lt;/code&gt;, &lt;code&gt;develop&lt;/code&gt;, release branches&lt;/td&gt;
&lt;td&gt;Merge, never rebase&lt;/td&gt;
&lt;td&gt;Everyone builds on them&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Finished feature into &lt;code&gt;main&lt;/code&gt;, you want context&lt;/td&gt;
&lt;td&gt;Merge commit (&lt;code&gt;--no-ff&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;One visible unit per feature, easy &lt;code&gt;revert -m 1&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Finished feature, many noisy commits&lt;/td&gt;
&lt;td&gt;Squash&lt;/td&gt;
&lt;td&gt;One tidy commit per pull request&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Finished feature, you want a straight line with every commit&lt;/td&gt;
&lt;td&gt;Rebase and fast-forward&lt;/td&gt;
&lt;td&gt;Linear history, each commit stays&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;You need to undo a pushed integration&lt;/td&gt;
&lt;td&gt;&lt;code&gt;revert&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Never rewrite published history&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A workflow that works for many teams, again as a recommendation: rebase locally while you work, open the pull request, let the team's chosen merge strategy (merge commit or squash) land it on &lt;code&gt;main&lt;/code&gt;, and never rebase a branch after someone else has pulled it. What matters more than the choice is that everyone on the team uses the same one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common mistakes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Rebasing a branch other people have pulled.&lt;/strong&gt; It strands their commits and creates confusing conflicts like the &lt;code&gt;add/add&lt;/code&gt; above.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Using&lt;/strong&gt;&lt;code&gt;git push --force&lt;/code&gt;&lt;strong&gt;.&lt;/strong&gt; Use &lt;code&gt;--force-with-lease&lt;/code&gt;. In my test the plain force deleted a teammate's commit from the remote.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rebasing&lt;/strong&gt;&lt;code&gt;main&lt;/code&gt;&lt;strong&gt;onto a feature branch.&lt;/strong&gt; The direction matters: rebase the &lt;em&gt;feature&lt;/em&gt; onto &lt;code&gt;main&lt;/code&gt;, never the other way around.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Panicking when commits seem to vanish after a rebase.&lt;/strong&gt; They are still there; use &lt;code&gt;ORIG_HEAD&lt;/code&gt; or &lt;code&gt;git reflog&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Resolving the same conflict repeatedly.&lt;/strong&gt; Squash first, or consider merging instead.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Deleting a squash-merged branch with&lt;/strong&gt;&lt;code&gt;-D&lt;/code&gt;&lt;strong&gt;without checking.&lt;/strong&gt; Git cannot tell it was merged.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Merging again after&lt;/strong&gt;&lt;code&gt;revert -m 1&lt;/code&gt;&lt;strong&gt;and getting "Already up to date".&lt;/strong&gt; Revert the revert instead.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ignoring the&lt;/strong&gt;&lt;code&gt;pull&lt;/code&gt;&lt;strong&gt;default.&lt;/strong&gt; Set &lt;code&gt;pull.rebase&lt;/code&gt; or &lt;code&gt;pull.ff&lt;/code&gt; once.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Alternatives to both
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;git cherry-pick&lt;/code&gt; to copy specific commits without merging the whole branch (see the &lt;a href="https://dev-talk.com/blog/git-stash-cherry-pick-worktrees" rel="noopener noreferrer"&gt;stash and cherry-pick part&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git rebase -i&lt;/code&gt; to reorder, edit and squash your commits before you share them.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git merge --squash&lt;/code&gt; when you want the changes but a single commit.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Related Dev Talk articles and tools
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dev-talk.com/post/git-branching-merging-resolving-conflicts" rel="noopener noreferrer"&gt;Git merge conflicts: branching, merging and how to resolve them&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev-talk.com/post/git-rebase-rewriting-history-safely" rel="noopener noreferrer"&gt;Git rebase explained: rewrite history without breaking it&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev-talk.com/post/git-undo-mistakes-reset-revert-reflog" rel="noopener noreferrer"&gt;Git undo commit: reset, revert and reflog recovery&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev-talk.com/post/git-daily-workflow-staging-commits-gitignore" rel="noopener noreferrer"&gt;Git daily workflow: staging, commits and .gitignore&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Tools: &lt;code&gt;git log --oneline --graph --decorate --all&lt;/code&gt; shows exactly what these examples show, and &lt;code&gt;git reflog&lt;/code&gt; is the safety net. A graphical client can draw the same graph; I did not use one here.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://docs.github.com/en/pull-requests/reference/pull-request-merges" rel="noopener noreferrer"&gt;GitHub Docs: Pull request merges&lt;/a&gt; (merge commit, squash and merge, rebase and merge)&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://dev-talk.com/post/git-merge-vs-rebase-practical-examples" rel="noopener noreferrer"&gt;DEV Talk&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>git</category>
      <category>gitmerge</category>
      <category>gitrebase</category>
      <category>versioncontrol</category>
    </item>
    <item>
      <title>Secure a Laravel App Before Production: Tested Checklist</title>
      <dc:creator>devTalk</dc:creator>
      <pubDate>Fri, 13 Nov 2026 03:38:46 +0000</pubDate>
      <link>https://dev.to/devtalk94/secure-a-laravel-app-before-production-tested-checklist-16a0</link>
      <guid>https://dev.to/devtalk94/secure-a-laravel-app-before-production-tested-checklist-16a0</guid>
      <description>&lt;p&gt;&lt;em&gt;Last updated: 8 November 2026. See the&lt;/em&gt;&lt;em&gt;update log&lt;/em&gt;&lt;em&gt;at the end.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Laravel gives you safe defaults for a lot of things: Blade escapes output, the query builder uses bound parameters, forms need a CSRF token, and session IDs change on login. But a handful of protections only exist if you set them up, and the dangerous ones fail silently. Nothing breaks when debug mode is on, when the web server points at the wrong folder, or when a user can open someone else's record by changing a number in the URL. The app just works, until someone finds it.&lt;/p&gt;

&lt;p&gt;This article is a pre-launch checklist where every item was reproduced against a real Laravel 13.40.0 app over HTTP, so you see the actual requests, responses and numbers, including the defaults that are not safe. For each item you get the problem, the evidence, the fix, and how to check it afterwards.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Laravel handles for you, and what it does not
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Risk&lt;/th&gt;
&lt;th&gt;Out of the box&lt;/th&gt;
&lt;th&gt;Your job&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;XSS in Blade&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;{{ }}&lt;/code&gt; escapes&lt;/td&gt;
&lt;td&gt;Never use &lt;code&gt;{!! !!}&lt;/code&gt; on user input&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SQL injection&lt;/td&gt;
&lt;td&gt;Bound parameters in the query builder and Eloquent&lt;/td&gt;
&lt;td&gt;Never interpolate variables into raw SQL&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CSRF&lt;/td&gt;
&lt;td&gt;Web routes reject a missing token with 419&lt;/td&gt;
&lt;td&gt;Be careful with exclusions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Session fixation&lt;/td&gt;
&lt;td&gt;Session ID regenerated on login&lt;/td&gt;
&lt;td&gt;Nothing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Debug output&lt;/td&gt;
&lt;td&gt;Enabled in the default &lt;code&gt;.env&lt;/code&gt; file&lt;/td&gt;
&lt;td&gt;Turn it off in production&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Mass assignment&lt;/td&gt;
&lt;td&gt;The skeleton's &lt;code&gt;User&lt;/code&gt; model whitelists fields&lt;/td&gt;
&lt;td&gt;Your own models and request handling&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Authorization&lt;/td&gt;
&lt;td&gt;Nothing automatic&lt;/td&gt;
&lt;td&gt;Every route that loads a record&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Brute-force protection&lt;/td&gt;
&lt;td&gt;Throttle middleware is available but not applied to your routes&lt;/td&gt;
&lt;td&gt;Add it&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Security headers&lt;/td&gt;
&lt;td&gt;None sent&lt;/td&gt;
&lt;td&gt;Add a middleware or set them at the web server&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Proxy and host trust&lt;/td&gt;
&lt;td&gt;Forwarded headers ignored by default&lt;/td&gt;
&lt;td&gt;Configure it correctly for your setup&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  1. Turn off debug mode and set the environment
&lt;/h2&gt;

&lt;p&gt;A fresh Laravel app's &lt;code&gt;.env&lt;/code&gt; has &lt;code&gt;APP_ENV=local&lt;/code&gt; and &lt;code&gt;APP_DEBUG=true&lt;/code&gt;. In production:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;APP_ENV&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;production
&lt;span class="nv"&gt;APP_DEBUG&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I made a route that throws an exception and requested it both ways:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;APP_DEBUG=true:   status 500, 842,814 bytes, 110 references to absolute server paths,
                  stack trace with source code
APP_DEBUG=false:  status 500, 6,592 bytes, a generic "Server Error" page
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The debug page told an attacker my directory layout, the framework internals and application code around the failure. I did not find &lt;code&gt;APP_KEY&lt;/code&gt; or database passwords in that page's text in this test, but file paths and code are already more than anyone should get from an error. Debug mode on staging servers that are reachable from the internet counts too. More on this in &lt;a href="https://dev-talk.com/laravel-production-mistakes" rel="noopener noreferrer"&gt;5 Laravel production mistakes that pass every local test&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Point the web server at public/, never the project root
&lt;/h2&gt;

&lt;p&gt;Only the &lt;code&gt;public&lt;/code&gt; folder should be reachable from the web. I served the project root instead of &lt;code&gt;public&lt;/code&gt; and requested &lt;code&gt;/.env&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;document root = project root:  GET /.env  -&amp;gt;  status 200, file contents returned (APP_KEY included)
document root = public/:       GET /.env  -&amp;gt;  status 404
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A web server pointed at the wrong folder serves your secrets to the world. In Nginx, set the root to &lt;code&gt;public&lt;/code&gt; and refuse dotfiles as a second line of defense. This follows the structure of the standard Laravel Nginx config; I did not run Nginx for this article:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight nginx"&gt;&lt;code&gt;&lt;span class="n"&gt;server&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;root&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;www&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;current&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;public&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;php&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="n"&gt;location&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;try_files&lt;/span&gt; $&lt;span class="n"&gt;uri&lt;/span&gt; $&lt;span class="n"&gt;uri&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;php&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;$&lt;span class="n"&gt;query_string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;location&lt;/span&gt; &lt;span class="o"&gt;~&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;\&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;?!&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;known&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;deny&lt;/span&gt; &lt;span class="n"&gt;all&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check it from outside after every infrastructure change:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -s -o /dev/null -w &lt;span class="s2"&gt;"%{http_code}\n"&lt;/span&gt; https://your-site.example/.env
&lt;span class="c"&gt;# expect 404 or 403, never 200&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3. Protect APP_KEY and plan for rotating it
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;APP_KEY&lt;/code&gt; encrypts cookies, sessions (if you encrypt them) and anything you pass through &lt;code&gt;Crypt&lt;/code&gt;. The skeleton's &lt;code&gt;.gitignore&lt;/code&gt; already ignores &lt;code&gt;.env&lt;/code&gt;, &lt;code&gt;.env.backup&lt;/code&gt; and &lt;code&gt;.env.production&lt;/code&gt;; keep it that way, and keep keys out of build logs and chat messages. The skeleton's session config sets &lt;code&gt;'serialization' =&amp;gt; 'json'&lt;/code&gt;, and its comment explains that this guards against "gadget chain" attacks if the key leaks.&lt;/p&gt;

&lt;p&gt;If a key does leak, you need to replace it without logging everyone out or breaking stored encrypted data. Laravel reads old keys from &lt;code&gt;APP_PREVIOUS_KEYS&lt;/code&gt; (comma separated) in &lt;code&gt;config/app.php&lt;/code&gt;. I tested the mechanism with the framework's encrypter:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;new key only:                  DecryptException: The MAC is invalid.
new key + previousKeys([old]): session-data
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;php artisan key:generate --show      &lt;span class="c"&gt;# prints a new key without writing it&lt;/span&gt;
&lt;span class="c"&gt;# then in .env:&lt;/span&gt;
&lt;span class="nv"&gt;APP_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;base64:NEW_KEY...
&lt;span class="nv"&gt;APP_PREVIOUS_KEYS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;base64:OLD_KEY...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;--show&lt;/code&gt; option is listed in the command's help ("Display a new key instead of modifying files"). Remove old keys once the data encrypted with them has expired or been re-encrypted. For storing the file itself, &lt;code&gt;php artisan env:encrypt&lt;/code&gt; and &lt;code&gt;env:decrypt&lt;/code&gt; exist in 13.40 (I listed them but did not run them), which lets you commit an encrypted environment file and keep the decryption key elsewhere.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Cache config in production, and stop calling env() outside config files
&lt;/h2&gt;

&lt;p&gt;This is partly a performance item and partly a security one, because it changes where your settings really come from. With the config cached, &lt;code&gt;env()&lt;/code&gt; outside &lt;code&gt;config/*.php&lt;/code&gt; no longer reads &lt;code&gt;.env&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;before config:cache:  {"env":"Laravel","config":"Laravel"}
after config:cache:   {"env":null,"config":"Laravel"}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Code like &lt;code&gt;if (env('APP_DEBUG'))&lt;/code&gt; in a controller then silently gets &lt;code&gt;null&lt;/code&gt;. Read settings with &lt;code&gt;config()&lt;/code&gt;, and put every &lt;code&gt;env()&lt;/code&gt; call in a config file. On deploy:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;php artisan optimize
php artisan about &lt;span class="o"&gt;|&lt;/span&gt; grep -E &lt;span class="s2"&gt;"Environment|Debug Mode|Config|Routes"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Environment ..................................................... production
Debug Mode ............................................................. OFF
Config .............................................................. CACHED
Routes .............................................................. CACHED
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That output is from my test app with production settings. &lt;code&gt;about&lt;/code&gt; is a fast way to confirm what a server is actually running.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Force HTTPS and secure cookies
&lt;/h2&gt;

&lt;p&gt;The default session cookie is &lt;code&gt;HttpOnly&lt;/code&gt; with &lt;code&gt;SameSite=Lax&lt;/code&gt;, but it has no &lt;code&gt;Secure&lt;/code&gt; flag, so a browser will send it over plain HTTP too. This is what the default response sends (values removed):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Set-Cookie: XSRF-TOKEN=...; path=/; samesite=lax
Set-Cookie: laravel-session=...; path=/; httponly; samesite=lax
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With &lt;code&gt;SESSION_SECURE_COOKIE=true&lt;/code&gt; in &lt;code&gt;.env&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Set-Cookie: XSRF-TOKEN=...; path=/; secure; samesite=lax
Set-Cookie: laravel-session=...; path=/; secure; httponly; samesite=lax
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;XSRF-TOKEN&lt;/code&gt; cookie is not &lt;code&gt;HttpOnly&lt;/code&gt; by design, so JavaScript can read it for AJAX requests. Redirect HTTP to HTTPS at the load balancer or web server, and send an HSTS header (see item 8). Setting the secure flag before your site is fully on HTTPS locks out your own sessions on HTTP, so do the two together.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Trust proxies precisely, never blindly
&lt;/h2&gt;

&lt;p&gt;Behind a load balancer, the app must read the real client IP and scheme from &lt;code&gt;X-Forwarded-*&lt;/code&gt; headers, but only from your proxy. By default Laravel ignores them, which is safe but means &lt;code&gt;isSecure()&lt;/code&gt; is false and every request appears to come from the proxy's IP. The tempting fix is &lt;code&gt;trustProxies(at: '*')&lt;/code&gt;. I tested all three configurations, sending forged &lt;code&gt;X-Forwarded-Proto&lt;/code&gt; and &lt;code&gt;X-Forwarded-For&lt;/code&gt; headers, then eight wrong logins (each with a different forged IP) against a route limited to five attempts per minute:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Configuration&lt;/th&gt;
&lt;th&gt;Forged headers accepted?&lt;/th&gt;
&lt;th&gt;8 login attempts with different forged IPs&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Default (none)&lt;/td&gt;
&lt;td&gt;No: &lt;code&gt;isSecure=false, ip=127.0.0.1&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;422 422 422 422 422 &lt;strong&gt;429 429 429&lt;/strong&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;at: '*'&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Yes: &lt;code&gt;isSecure=true, ip=1.2.3.4&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;422 422 422 422 422 422 422 422 (&lt;strong&gt;throttle bypassed&lt;/strong&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;at: '10.0.0.0/8'&lt;/code&gt; (not the sender)&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;422 422 422 422 422 &lt;strong&gt;429 429 429&lt;/strong&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// bootstrap/app.php&lt;/span&gt;
&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;withMiddleware&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Middleware&lt;/span&gt; &lt;span class="nv"&gt;$middleware&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;$middleware&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;trustProxies&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;at&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'10.0.0.0/8'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c1"&gt;// your load balancer's address range&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With &lt;code&gt;at: '*'&lt;/code&gt; any client could pretend to be any IP, which defeats IP-based throttling and corrupts your logs. Using &lt;code&gt;'*'&lt;/code&gt; is only reasonable when the app can be reached exclusively through the proxy, for example inside a private network where the proxy is the only way in. Otherwise list your proxy's IP or CIDR range. The method also takes an array, which I did not test.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Trust your own hostnames
&lt;/h2&gt;

&lt;p&gt;Laravel builds URLs from the request's &lt;code&gt;Host&lt;/code&gt; header unless told otherwise. A password-reset email that uses &lt;code&gt;url()&lt;/code&gt; or &lt;code&gt;route()&lt;/code&gt; can then link to an attacker's domain if they send a forged &lt;code&gt;Host&lt;/code&gt;. I requested a route that returns &lt;code&gt;url('/reset-password/abc123')&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -s -H &lt;span class="s2"&gt;"Host: evil.example"&lt;/span&gt; http://127.0.0.1:8300/host
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{"host":"evil.example","url":"http://evil.example/reset-password/abc123", ...}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The fix is &lt;code&gt;trustHosts&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$middleware&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;trustHosts&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;at&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'^app\.example\.com$'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;APP_ENV=production, Host: evil.example     -&amp;gt; status 400
APP_ENV=production, Host: 127.0.0.1:8300   -&amp;gt; status 200 (an allowed host)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One trap I hit: the middleware does nothing when &lt;code&gt;APP_ENV=local&lt;/code&gt;. The framework's &lt;code&gt;shouldSpecifyTrustedHosts()&lt;/code&gt; returns false in the local environment and in unit tests, so in my first attempt the forged host still got a 200. Test it with production settings, or you will believe it works when it does not.&lt;/p&gt;

&lt;h2&gt;
  
  
  8. Send security headers
&lt;/h2&gt;

&lt;p&gt;Laravel sends none. A small middleware covers the common ones:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;?&lt;/span&gt;&lt;span class="n"&gt;php&lt;/span&gt;

&lt;span class="k"&gt;namespace&lt;/span&gt; &lt;span class="nc"&gt;App&lt;/span&gt;\&lt;span class="nc"&gt;Http&lt;/span&gt;\&lt;span class="nc"&gt;Middleware&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;Closure&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;Illuminate&lt;/span&gt;\&lt;span class="nc"&gt;Http&lt;/span&gt;\&lt;span class="nc"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;Symfony&lt;/span&gt;\&lt;span class="nc"&gt;Component&lt;/span&gt;\&lt;span class="nc"&gt;HttpFoundation&lt;/span&gt;\&lt;span class="nc"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;SecurityHeaders&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;handle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Request&lt;/span&gt; &lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Closure&lt;/span&gt; &lt;span class="nv"&gt;$next&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Response&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$next&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="nv"&gt;$response&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'X-Content-Type-Options'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'nosniff'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nv"&gt;$response&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'X-Frame-Options'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'DENY'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nv"&gt;$response&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Referrer-Policy'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'strict-origin-when-cross-origin'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nv"&gt;$response&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Permissions-Policy'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'camera=(), microphone=(), geolocation=()'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;isSecure&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nv"&gt;$response&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Strict-Transport-Security'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'max-age=31536000; includeSubDomains'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$response&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// bootstrap/app.php&lt;/span&gt;
&lt;span class="nv"&gt;$middleware&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;\&lt;span class="nc"&gt;App&lt;/span&gt;\&lt;span class="nc"&gt;Http&lt;/span&gt;\&lt;span class="nc"&gt;Middleware&lt;/span&gt;\&lt;span class="nc"&gt;SecurityHeaders&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="k"&gt;class&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;X-Content-Type-Options: nosniff
X-Frame-Options: DENY
Referrer-Policy: strict-origin-when-cross-origin
Permissions-Policy: camera=(), microphone=(), geolocation=()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;HSTS only appears when the request is seen as secure, so it depends on item 6: behind an HTTPS-terminating proxy that you have not trusted, &lt;code&gt;isSecure()&lt;/code&gt; is false and the header is never sent (I confirmed both outcomes in the table above, with HSTS present only under &lt;code&gt;at: '*'&lt;/code&gt;). Start with a short &lt;code&gt;max-age&lt;/code&gt; while you test, because browsers remember HSTS. A &lt;code&gt;Content-Security-Policy&lt;/code&gt; is the strongest header against XSS, but it needs tuning to your scripts and styles, so I left it out of this generic example.&lt;/p&gt;

&lt;p&gt;The test server also sent &lt;code&gt;X-Powered-By: PHP/8.3.6&lt;/code&gt;. Set &lt;code&gt;expose_php = Off&lt;/code&gt; in &lt;code&gt;php.ini&lt;/code&gt; to stop advertising the version (standard PHP setting, not tested here).&lt;/p&gt;

&lt;h2&gt;
  
  
  9. Keep CSRF protection on
&lt;/h2&gt;

&lt;p&gt;In Laravel 13.40 the web middleware group includes &lt;code&gt;PreventRequestForgery&lt;/code&gt;, and the older &lt;code&gt;VerifyCsrfToken&lt;/code&gt; class is a deprecated subclass of it. A POST without a token:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -s -o /dev/null -w &lt;span class="s2"&gt;"%{http_code}\n"&lt;/span&gt; -X POST http://127.0.0.1:8300/ping
&lt;span class="c"&gt;# 419&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you must exclude a route, such as a payment provider's webhook, do it narrowly, and verify the sender some other way (a signature check), because an excluded route has no CSRF protection at all:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$middleware&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;preventRequestForgery&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;except&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'webhooks/stripe'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The method also has &lt;code&gt;originOnly&lt;/code&gt; and &lt;code&gt;allowSameSite&lt;/code&gt; options in the 13.40 source; read their docs before changing them. If real users hit 419 errors, see &lt;a href="https://dev-talk.com/laravel-419-page-expired" rel="noopener noreferrer"&gt;Laravel 419 Page Expired: causes and fixes&lt;/a&gt; rather than turning the protection off.&lt;/p&gt;

&lt;h2&gt;
  
  
  10. Harden login: hashing, throttling, sessions
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Hashing.&lt;/strong&gt; The skeleton sets &lt;code&gt;BCRYPT_ROUNDS=12&lt;/code&gt;. Cost doubles with each extra round, so measure on your hardware. On this machine:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bcrypt rounds=10:   51 ms
bcrypt rounds=12:  198 ms
bcrypt rounds=14:  796 ms
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Those are single runs; the pattern (about 4 times slower per two rounds) is what matters. Pick the highest cost your login endpoint can afford under load, and use &lt;code&gt;Hash::needsRehash()&lt;/code&gt; at login to upgrade old hashes as users sign in. PHP here also offered &lt;code&gt;argon2i&lt;/code&gt; and &lt;code&gt;argon2id&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Throttling.&lt;/strong&gt; Login routes need a rate limit. The built-in middleware worked as expected on a route with &lt;code&gt;throttle:5,1&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;attempt 1-5 -&amp;gt; 422  X-RateLimit-Limit: 5  X-RateLimit-Remaining: 4 ... 0
attempt 6   -&amp;gt; 429  Retry-After: 59
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For guests that limit is keyed by IP address, which is why item 6 matters. A more targeted limiter keys on the account as well. This is the standard form from the Laravel documentation, not something I ran:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;Illuminate&lt;/span&gt;\&lt;span class="nc"&gt;Cache&lt;/span&gt;\&lt;span class="nc"&gt;RateLimiting&lt;/span&gt;\&lt;span class="nc"&gt;Limit&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;Illuminate&lt;/span&gt;\&lt;span class="nc"&gt;Support&lt;/span&gt;\&lt;span class="nc"&gt;Facades&lt;/span&gt;\&lt;span class="nc"&gt;RateLimiter&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nc"&gt;RateLimiter&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'login'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Request&lt;/span&gt; &lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Limit&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;perMinute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;by&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;strtolower&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'email'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="s1"&gt;'|'&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;ip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Route::post('/login', ...)-&amp;gt;middleware('throttle:login');&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For API limits and algorithms in depth, see &lt;a href="https://dev-talk.com/api-rate-limiting-strategies" rel="noopener noreferrer"&gt;API rate limiting strategies&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sessions.&lt;/strong&gt; &lt;code&gt;Auth::attempt()&lt;/code&gt; regenerates the session ID, which blocks session fixation. I checked it in the &lt;code&gt;sessions&lt;/code&gt; table: before login the newest row had a null &lt;code&gt;user_id&lt;/code&gt;; after login the ID was different and &lt;code&gt;user_id&lt;/code&gt; was set. In the source this is &lt;code&gt;$this-&amp;gt;session-&amp;gt;regenerate(true)&lt;/code&gt; in &lt;code&gt;SessionGuard::updateSession()&lt;/code&gt;. If you write your own login code, call &lt;code&gt;$request-&amp;gt;session()-&amp;gt;regenerate()&lt;/code&gt; yourself.&lt;/p&gt;

&lt;h2&gt;
  
  
  11. Authorize every record access (the IDOR check)
&lt;/h2&gt;

&lt;p&gt;Authentication tells you who the user is. Authorization decides what they may touch. Route model binding fetches any record, for anyone, unless you check. I logged in as &lt;code&gt;alice&lt;/code&gt; and requested &lt;code&gt;bob&lt;/code&gt;'s record on two routes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// No check: any logged-in user can read any user's email&lt;/span&gt;
&lt;span class="nc"&gt;Route&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'/users/{user}/email-unsafe'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;User&lt;/span&gt; &lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;middleware&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'auth'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// With an ownership check&lt;/span&gt;
&lt;span class="nc"&gt;Route&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'/users/{user}/email-safe'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;User&lt;/span&gt; &lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;Gate&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;allowIf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$auth&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$auth&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;is&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;middleware&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'auth'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;alice reads bob, no check:      bob@example.test
alice reads bob, ownership check: status 403
alice reads herself:             alice@example.test
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For real apps, use policies (&lt;code&gt;$this-&amp;gt;authorize('view', $invoice)&lt;/code&gt; or &lt;code&gt;Gate::authorize()&lt;/code&gt;) and write a test per resource that logs in as a second user and expects a 403. This is the bug most likely to survive review, because no error ever appears.&lt;/p&gt;

&lt;h2&gt;
  
  
  12. Block mass assignment
&lt;/h2&gt;

&lt;p&gt;Passing &lt;code&gt;$request-&amp;gt;all()&lt;/code&gt; into &lt;code&gt;create()&lt;/code&gt; lets a client set any column, including ones your form never showed. Laravel 13's skeleton &lt;code&gt;User&lt;/code&gt; model whitelists fields with an attribute:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;#[Fillable(['name', 'email', 'password'])]&lt;/span&gt;
&lt;span class="c1"&gt;#[Hidden(['password', 'remember_token'])]&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;User&lt;/span&gt; &lt;span class="k"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Authenticatable&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* ... */&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I compared that with an unguarded model on the same table (&lt;code&gt;protected $guarded = [];&lt;/code&gt;), posting &lt;code&gt;is_admin=1&lt;/code&gt; to both:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Vulnerable&lt;/span&gt;
&lt;span class="nv"&gt;$u&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;LooseUser&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;all&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Safer: validate, and use only validated data on a model that whitelists fields&lt;/span&gt;
&lt;span class="nv"&gt;$data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;validate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="s1"&gt;'name'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'required|string|max:100'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s1"&gt;'email'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'required|email|unique:users'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s1"&gt;'password'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'required|min:12'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;$u&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;unguarded model + $request-&amp;gt;all():       {"is_admin":1}
validated data + whitelisted model:      {"is_admin":0}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Treat &lt;code&gt;$guarded = []&lt;/code&gt; as a bug unless the data is never from a request. In development, &lt;code&gt;Model::shouldBeStrict()&lt;/code&gt; turns silently discarded attributes into exceptions (see the &lt;a href="https://dev-talk.com/laravel-13-performance-optimization" rel="noopener noreferrer"&gt;performance article&lt;/a&gt; for how it behaves).&lt;/p&gt;

&lt;h2&gt;
  
  
  13. Never interpolate into SQL, never print raw HTML
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;SQL.&lt;/strong&gt; Bound parameters are the defense. Here are two raw queries, one with the input pasted into the string and one with a placeholder, given the classic payload &lt;code&gt;' OR '1'='1&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Vulnerable&lt;/span&gt;
&lt;span class="no"&gt;DB&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;select&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"select id, name from users where name = '{$request-&amp;gt;query('name')}'"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Safe&lt;/span&gt;
&lt;span class="no"&gt;DB&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;select&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'select id, name from users where name = ?'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;query&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'name'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;interpolated: [{"id":1,"name":"alice"},{"id":2,"name":"bob"}]   (every row returned)
bound:        []
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The same rule applies to &lt;code&gt;whereRaw()&lt;/code&gt;, &lt;code&gt;selectRaw()&lt;/code&gt; and &lt;code&gt;orderByRaw()&lt;/code&gt;. Bindings protect values, not column names: if a user chooses the sort column, check it against an allow-list. See &lt;a href="https://dev-talk.com/eloquent-vs-query-builder" rel="noopener noreferrer"&gt;Eloquent vs Query Builder&lt;/a&gt; for when each fits.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;XSS.&lt;/strong&gt; I rendered &lt;code&gt;&amp;lt;script&amp;gt;alert(1)&amp;lt;/script&amp;gt;&lt;/code&gt; both ways:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{{ $q }}     -&amp;gt; &amp;lt;p&amp;gt;escaped: &amp;amp;lt;script&amp;amp;gt;alert(1)&amp;amp;lt;/script&amp;amp;gt;&amp;lt;/p&amp;gt;
{!! $q !!}   -&amp;gt; &amp;lt;p&amp;gt;raw: &amp;lt;script&amp;gt;alert(1)&amp;lt;/script&amp;gt;&amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use &lt;code&gt;{!! !!}&lt;/code&gt; only for HTML you generated yourself. If users may submit HTML, run it through a sanitizer first (I did not test one) and add a Content-Security-Policy.&lt;/p&gt;

&lt;h2&gt;
  
  
  14. Treat uploads as hostile
&lt;/h2&gt;

&lt;p&gt;Never trust the file extension or the client's content type. I uploaded a real PNG, a PHP script renamed &lt;code&gt;evil.jpg&lt;/code&gt; (sent with &lt;code&gt;Content-Type: image/jpeg&lt;/code&gt;) and a file named &lt;code&gt;evil.php&lt;/code&gt;, against this validation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;validate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="s1"&gt;'avatar'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'required'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'image'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'mimes:jpg,jpeg,png'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'max:2048'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;$path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;file&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'avatar'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;store&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'avatars'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;real.png  -&amp;gt; {"stored":"avatars/JNQgygKEpFyrUOQkyojulvOi4gEUyGBJvg1fq290.png"}
evil.jpg  -&amp;gt; "The avatar field must be an image." / "must be a file of type: jpg, jpeg, png."
evil.php  -&amp;gt; the same two errors
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Laravel checks the file's real content, so renaming does not pass. Two more details from the result: the stored name is random (&lt;code&gt;store()&lt;/code&gt; generates it, so never use the client's filename), and the file landed in &lt;code&gt;storage/app/private/avatars/&lt;/code&gt;, outside the web root. Keep uploads on a private disk and serve them through a controller or signed URLs unless they must be public. Also set a request size limit at the web server and in PHP (&lt;code&gt;upload_max_filesize&lt;/code&gt;, &lt;code&gt;post_max_size&lt;/code&gt;), which I did not test.&lt;/p&gt;

&lt;h2&gt;
  
  
  15. Audit dependencies and keep patching
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;composer install --no-dev --optimize-autoloader   &lt;span class="c"&gt;# no dev tools on the server&lt;/span&gt;
composer audit                                      &lt;span class="c"&gt;# check installed packages against known advisories&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;composer audit&lt;/code&gt; command is present in Composer 2.8.12 here. I could not run it, because it fetches advisories from Packagist, which this environment cannot reach. Run it in CI on every build and on a schedule, since new advisories appear for code you have not changed. Keep the framework current within your major version (this article's tests used 13.40.0), and read the release notes of security releases. If you are on Laravel 12, see the &lt;a href="https://dev-talk.com/upgrade-laravel-12-to-13" rel="noopener noreferrer"&gt;12 to 13 upgrade guide&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Infrastructure items I did not test
&lt;/h2&gt;

&lt;p&gt;These matter just as much and live outside the Laravel app, so verify them in your own environment:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The database, Redis and any queue backend should not be reachable from the internet. Bind to private addresses and use a firewall or security group.&lt;/li&gt;
&lt;li&gt;Use separate database users for the app and for migrations, with the least privileges that work.&lt;/li&gt;
&lt;li&gt;Only &lt;code&gt;storage&lt;/code&gt; and &lt;code&gt;bootstrap/cache&lt;/code&gt; need to be writable by the web server user.&lt;/li&gt;
&lt;li&gt;Keep backups, and test restoring one.&lt;/li&gt;
&lt;li&gt;Do not log passwords, tokens or full request bodies.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Pre-launch checklist
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;#&lt;/th&gt;
&lt;th&gt;Check&lt;/th&gt;
&lt;th&gt;How to verify&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;APP_ENV=production&lt;/code&gt;, &lt;code&gt;APP_DEBUG=false&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;&lt;code&gt;php artisan about&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;Document root is &lt;code&gt;public/&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;curl -I https://site/.env&lt;/code&gt; returns 404 or 403&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;Key not in git, rotation plan exists&lt;/td&gt;
&lt;td&gt;Check &lt;code&gt;.gitignore&lt;/code&gt;, note &lt;code&gt;APP_PREVIOUS_KEYS&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;Config cached, no &lt;code&gt;env()&lt;/code&gt; outside config&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;php artisan optimize&lt;/code&gt;, search for &lt;code&gt;env(&lt;/code&gt; in &lt;code&gt;app/&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;HTTPS redirect and secure cookies&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;SESSION_SECURE_COOKIE=true&lt;/code&gt;, inspect &lt;code&gt;Set-Cookie&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;Trusted proxies set to your proxy only&lt;/td&gt;
&lt;td&gt;Forged &lt;code&gt;X-Forwarded-For&lt;/code&gt; does not change &lt;code&gt;$request-&amp;gt;ip()&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;td&gt;Trusted hosts set&lt;/td&gt;
&lt;td&gt;Forged &lt;code&gt;Host&lt;/code&gt; gets a 400 in production mode&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;Security headers present&lt;/td&gt;
&lt;td&gt;`curl -sI &lt;a href="https://site" rel="noopener noreferrer"&gt;https://site&lt;/a&gt; \&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;9&lt;/td&gt;
&lt;td&gt;CSRF on, exclusions justified&lt;/td&gt;
&lt;td&gt;POST without a token returns 419&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;td&gt;Login throttled&lt;/td&gt;
&lt;td&gt;Sixth bad attempt returns 429&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;11&lt;/td&gt;
&lt;td&gt;Policies on every record route&lt;/td&gt;
&lt;td&gt;A second-user test expects 403&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;12&lt;/td&gt;
&lt;td&gt;No {% raw %}&lt;code&gt;$guarded = []&lt;/code&gt; with request data&lt;/td&gt;
&lt;td&gt;Search for &lt;code&gt;guarded&lt;/code&gt; and &lt;code&gt;$request-&amp;gt;all()&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;13&lt;/td&gt;
&lt;td&gt;No interpolated raw SQL, no raw Blade output&lt;/td&gt;
&lt;td&gt;Search for &lt;code&gt;Raw(&lt;/code&gt;, &lt;code&gt;DB::select("&lt;/code&gt; and &lt;code&gt;{!!&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;14&lt;/td&gt;
&lt;td&gt;Uploads validated and stored privately&lt;/td&gt;
&lt;td&gt;Upload a renamed script and expect a validation error&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;15&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;composer audit&lt;/code&gt; clean in CI&lt;/td&gt;
&lt;td&gt;CI job output&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Common mistakes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Checking security only in the local environment.&lt;/strong&gt; Trusted hosts does nothing in &lt;code&gt;local&lt;/code&gt;, and debug is on by default there.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Using&lt;/strong&gt;&lt;code&gt;trustProxies(at: '*')&lt;/code&gt;&lt;strong&gt;because it makes HTTPS detection work.&lt;/strong&gt; It also makes IP addresses forgeable.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Authenticating but not authorizing.&lt;/strong&gt; &lt;code&gt;middleware('auth')&lt;/code&gt; only proves someone is logged in.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Disabling CSRF globally to fix a 419.&lt;/strong&gt; Find the cause instead.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Validating by file extension.&lt;/strong&gt; Use content-based rules and a private disk.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Relying on a WAF or CDN instead of fixing the app.&lt;/strong&gt; They reduce noise; they do not repair an IDOR.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Committing&lt;/strong&gt;&lt;code&gt;.env.production&lt;/code&gt;&lt;strong&gt;.&lt;/strong&gt; The skeleton ignores it for a reason.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Related Dev Talk articles and tools
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dev-talk.com/post/api-rate-limiting-strategies" rel="noopener noreferrer"&gt;API rate limiting strategies&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev-talk.com/post/laravel-cors-error-react-vue-frontend" rel="noopener noreferrer"&gt;Laravel CORS errors with a React or Vue frontend&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev-talk.com/post/mysql-too-many-connections" rel="noopener noreferrer"&gt;MySQL "Too many connections"&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Tools: &lt;code&gt;composer audit&lt;/code&gt;, &lt;code&gt;php artisan about&lt;/code&gt;, and &lt;code&gt;curl -I&lt;/code&gt; for checking headers and exposed files from outside. A static analyzer such as PHPStan or Larastan and a scanner like OWASP ZAP help too; I did not run them for this article.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently asked questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Is Laravel secure by default?
&lt;/h3&gt;

&lt;p&gt;For the common injection and CSRF cases, yes, as the tests above show. It is not secure by default in the areas that depend on your configuration and your code: debug mode, web server layout, proxy and host trust, throttling, headers and authorization.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is the difference between APP_ENV and APP_DEBUG?
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;APP_DEBUG&lt;/code&gt; controls whether detailed errors are shown. &lt;code&gt;APP_ENV&lt;/code&gt; names the environment, and some framework behavior depends on it, such as trusted hosts, which is skipped in &lt;code&gt;local&lt;/code&gt;. Set both.&lt;/p&gt;

&lt;h3&gt;
  
  
  Do I need all of these if I'm behind Cloudflare or a load balancer?
&lt;/h3&gt;

&lt;p&gt;Yes. A proxy does not know your business rules, so it cannot fix a missing authorization check, mass assignment or unsafe SQL. It also makes the proxy-trust settings more important, not less.&lt;/p&gt;

&lt;h3&gt;
  
  
  Should staging have debug mode off too?
&lt;/h3&gt;

&lt;p&gt;If it is reachable from the internet, yes, and it should not contain real customer data.&lt;/p&gt;

&lt;h3&gt;
  
  
  How often should I run composer audit?
&lt;/h3&gt;

&lt;p&gt;On every CI build, plus a scheduled run (daily or weekly), because advisories are published for code you did not change.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://dev-talk.com/post/secure-laravel-applications-before-production" rel="noopener noreferrer"&gt;DEV Talk&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>laravel13</category>
      <category>security</category>
      <category>production</category>
      <category>csrf</category>
    </item>
  </channel>
</rss>
