frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Patch applies fake diffs from commit messages

https://samizdat.dev/phantom-patch/
48•reconquestio•1d ago

Comments

LiamPowell•1h ago
This has come up multiple times before [1], and more generally it's come up hundreds of times with Unix style tools in general. It's always been a stupid idea for every tool to have its own barely documented file format.

This wouldn't be an issue if patches were XML or JSON with a well defined schema, but everything must be a boutique undocumented format in the world of Unix tools.

Maybe the worst part about this is that it can entirely come from a patch being exported by git and then imported straight back in to git. If you can't even handle your own undocumented format then what hope do other tools have that want to work with it?

[1]: https://mas.to/@zekjur/116022397626943871

yjftsjthsd-h•1h ago
> This wouldn't be an issue if patches were XML or JSON with a well defined schema, but everything must be a boutique undocumented format in the world of Unix tools.

Patch files are readable by humans. Replacing them with XML or JSON would fix this problem, but at the expense of removing a core feature.

syntheticnature•1h ago
Haha, good one. Much like Makefiles, patch format precedes a lot of more modern things (by decades!) and is good enough to stick around. Unlike Makefiles, I've never seen tool gain any acceptance at all to replace patch.
tetha•26m ago
And a lot of these older tools are not meant to be fed untrusted, unvetted input. The patch shown there confused me for quite a bit.

Or, more snarky: tee is also a huge security problem if you pipe untrusted input into `tee -a /etc/passwd`, such as `curl | tee -a /etc/passwd`. Not many things are safe with a `curl |` in front of them. I think yes might be?

pwdisswordfishs•37m ago
> This wouldn't be an issue if patches were XML or JSON

Or MIME, even.

kevin_thibedeau•25m ago

  Patch: 1985
  SGML: 1986
chrishill89•23m ago
> Maybe the worst part about this is that it can entirely come from a patch being exported by git and then imported straight back in to git.

No one wants to apply diffs in commit messages. But some people use this technique via email:

    Finally fix it

    ---

    Changes in v2:

    - Proper formatting
    - Remove irrelevant typo fix
They’ve used the `---` commit message delimiter in the commit message itself so that everything after it won’t be applied by git-am(1). So that’s intentional loss of round tripping.

I would personally use Git notes instead though.

    Finally fix it

    ---

    Notes:
        Changes in v2: ...
Groxx•1h ago
Seems like this would probably be solved if github returned a patch file formatted like `git show` provides, specifically with the commit message indented? I do see that `git format-patch` doesn't do this indentation though.

In any case, agreed that it's not a great "feature" to use in-band signaling of when patch data starts, with no escaping. Confusion and misbehavior is pretty much guaranteed.

thaumasiotes•10m ago
> Seems like this would probably be solved if github returned a patch file formatted like `git show` provides, specifically with the commit message indented? I do see that `git format-patch` doesn't do this indentation though.

This would be "solved" if the patch file only included the patch. That's pretty straightforward. The file github provides includes fake email headers for no particular reason. The commit message appears to be part of the subject header. The subject header is never terminated, so arguably applying this patch shouldn't do anything. (Because the actual patch data is also part of the email headers.) The other headers aren't terminated either, so actually there is no subject header. This shouldn't really matter, because the patch file isn't email, but it does seem to want to pretend to be.

The usual question to ask here would be "why are you applying patch files from an untrusted source?". If patch(1) was stricter about the format of its input files... applying patches from an untrusted source would still be a good way to get owned. If you think I can get you to patch inappropriate files by writing a fake diff into my commit message... wait until you see what I can do by writing those same changes into the real diff.

chrishill89•1h ago
git-am(1) (apply patches) delimits the commit message from the patch/diff by looking for (1) a line `---` or (2) a line that starts with `diff -` or (3) a line that starts with `Index:SP` (SP is space). Only the first rule is necessary for patches generated git-format-patch(1). But git-am(1) is for applying patches, and you are free to bring patches from some other system. That’s why, I suppose, there are multiple options.

This means that it will try to apply any unindented diffs in the commit message. But you’re fine if you indent the diff. (Newschool code fencers will have a worse time here.)

I imagine that this worked fine for changes that were authored by one person and submitted by another person via email, or by their friend, or by someone trying to resurrect a previous attempt at getting something upstreamed. Someone is likely to notice that examples diffs are getting applied. But it won’t work well at all if you are some software distributor who is using patch files to apply modifications to packages.

Recall that git-am(1) will not apply indented diffs. Well have a look at my GNU patch 2.7.6:

    If the entire diff is indented by a consistent amount, if lines end in
    CRLF, or if a diff is encapsulated one or more times by prepending "- "
    to lines starting with "-" as specified by Internet RFC 934, this is
    taken into account.
Some may say that patch(1) should work like a more straightforward importer. But I’ve been itching to point out something else.

    Larry Wall wrote the original version of patch.
Is it surprising if patch(1) is a bit DWIM?

Ghostty is leaving GitHub

https://mitchellh.com/writing/ghostty-leaving-github
830•WadeGrimridge•1h ago•228 comments

OpenAI models coming to Amazon Bedrock: Interview with OpenAI and AWS CEOs

https://stratechery.com/2026/an-interview-with-openai-ceo-sam-altman-and-aws-ceo-matt-garman-abou...
96•translocator•1h ago•28 comments

I Won a Championship That Doesn't Exist

https://ron.stoner.com/How_I_Won_a_Championship_That_Doesnt_Exist/
18•SEJeff•38m ago•7 comments

A playable DOOM MCP app

https://chrisnager.com/blog/doom-runs-in-chatgpt-and-claude/
61•chrisnager•2h ago•25 comments

Warp is now Open-Source

https://github.com/warpdotdev/warp
121•doppp•4h ago•54 comments

Intel Arc Pro B70 Review

https://www.pugetsystems.com/labs/articles/intel-arc-pro-b70-review/
32•zdw•4d ago•6 comments

BP profits more than double as Iran war sends oil prices higher

https://www.bbc.com/news/articles/c2eveyvgn9no
17•breve•26m ago•2 comments

CJIT: C, Just in Time

https://dyne.org/cjit/
45•smartmic•2h ago•10 comments

Your phone is about to stop being yours

https://keepandroidopen.org/en/
672•doener•5h ago•352 comments

Patch applies fake diffs from commit messages

https://samizdat.dev/phantom-patch/
48•reconquestio•1d ago•10 comments

Waymo in Portland

https://waymo.com/blog/shorts/waymo-in-portland/
194•xnx•3h ago•242 comments

Claude.ai unavailable and elevated errors on the API

https://status.claude.com/incidents/9l93x2ht4s5w
224•shorsher•3h ago•190 comments

GitHub RCE Vulnerability: CVE-2026-3854 Breakdown

https://www.wiz.io/blog/github-rce-vulnerability-cve-2026-3854
155•bo0tzz•5h ago•41 comments

I have officially retired from Emacs

https://nullprogram.com/blog/2026/04/26/
148•Fudgel•2d ago•84 comments

Infisical (YC W23) Is Hiring Full Stack Software Engineers (Remote)

https://jobs.ashbyhq.com/infisical/782b9da8-20e1-48b2-919e-6c5430c58628
1•vmatsiiako•4h ago

Localsend: An open-source cross-platform alternative to AirDrop

https://github.com/localsend/localsend
699•bilsbie•9h ago•217 comments

UAE to leave OPEC

https://www.ft.com/content/8c354f2d-3e66-47f1-aad4-9b4aa30e386d
273•bazzmt•8h ago•387 comments

VibeVoice: Open-source frontier voice AI

https://github.com/microsoft/VibeVoice
291•tosh•9h ago•162 comments

Warp is now open-source

https://www.warp.dev/blog/warp-is-now-open-source
94•meetpateltech•5h ago•36 comments

Show HN: Drive any macOS app in the background without stealing the cursor

https://github.com/trycua/cua
13•frabonacci•5h ago•7 comments

Show HN: Live Sun and Moon Dashboard with NASA Footage

https://www.lumara-space.app/
146•beeswaxpat•7h ago•46 comments

AISLE Discovers 38 CVEs in OpenEMR Healthcare Software

https://aisle.com/blog/aisle-discovers-38-critical-security-vulnerabilities-in-healthcare-softwar...
157•mmsc•5h ago•101 comments

Laguna XS.2 and M.1

https://poolside.ai/blog/laguna-a-deeper-dive
83•tosh•4h ago•38 comments

GitHub Actions is the weakest link

https://nesbitt.io/2026/04/28/github-actions-is-the-weakest-link.html
179•dochtman•9h ago•60 comments

Talkie: a 13B vintage language model from 1930

https://talkie-lm.com/introducing-talkie
617•jekude•23h ago•248 comments

Things C++26 define_static_array can't do

https://quuxplusone.github.io/blog/2026/04/24/define-static-array/
38•jandeboevrie•2d ago•15 comments

ASML became the chokepoint for cutting-edge chips

https://worksinprogress.co/issue/the-worlds-most-complex-machine/
306•mellosouls•3d ago•188 comments

GitHub Copilot code review will start consuming GitHub Actions minutes

https://github.blog/changelog/2026-04-27-github-copilot-code-review-will-start-consuming-github-a...
218•whtsky•12h ago•153 comments

A good AGENTS.md is a model upgrade. A bad one is worse than no docs at all

https://www.augmentcode.com/blog/how-to-write-good-agents-dot-md-files
69•gmays•2h ago•20 comments

Drone pilot makes US rescind no-fly zones around unmarked, moving ICE vehicles

https://arstechnica.com/gadgets/2026/04/no-fly-zones-around-moving-ice-vehicles-this-drone-pilot-...
24•Bender•46m ago•3 comments