News for hackers. Stuff that matters.
Re:The way CTRL-C in Postgres CLI cancels queries is incredi... by i18nagentai on Monday March 23, 2026 @08:28AM (#47488525)
What strikes me most about this is how it illustrates the tension between backward compatibility and security in long-lived systems. The cancel key approach made total sense in the context of early Unix networking assumptions, but those assumptions have quietly eroded over decades. The fact that the cancel token is only 32 bits of entropy and sent in cleartext means it was never really designed for adversarial environments -- it was a convenience feature that became load-bearing infrastructure. I wonder if the Postgres community will eventually move toward a multiplexed protocol layer (similar to what HTTP/2 did for HTTP) rather than trying to bolt security onto the existing out-of-band mechanism.
Re:The way CTRL-C in Postgres CLI cancels queries is incredi... by dmurray on Monday March 23, 2026 @08:39AM (#47488661)
Doesn't it also make sense in the context of modern networking assumptions?

I've never had to connect to PostGres in an adversarial environment. I've been at work or at home and I connected to PostGres instances owned by me or my employer. If I tried to connect to my work instance from a coffee shop, the first thing I'd do would be to log in to a VPN. That's your multiplexed protocol layer right there: the security happens at the network layer and your cancel happens at the application layer.

This is a different situation from websites. I connect to websites owned by third parties all the time, and I want my communication there to be encrypted at the application layer.

Re:The way CTRL-C in Postgres CLI cancels queries is incredi... by somat on Monday March 23, 2026 @11:23AM (#47490783)
It makes me think of ipsec, ipsec was originally intended to be used sort of the the same as we use tls today, but application independent. when making a connection to a random remote machine the os would see if it could spool up a ipsec sa. No changes to a user program would be needed. But while they were faffing about trying to overcomplicate ipsec ssl came along and stole it's lunch money.

This application of ipsec was never used and barely implemented. Today getting it to make ad-hoc connections is a tricky untested edge case and ipsec was regulated to dedicated tunnels. Where everyone hates it because it is too tricky to get the parameters aligned.

There is definitely a case to be made that it is right and proper that secure connections are handled in the application(tls), But sometimes I like to think of how it could have been. where all applications get a secure connection whether they want one or not.

As a useless dangling side thought, an additional piece would be needed for ad-hoc ipsec that as far as I know was never implemented, a way to notify the OS that this connection must be encrypted(a socket option? SO_ENC?). This is most of the case for encrypted connections being the duty of the application.

Re:The way CTRL-C in Postgres CLI cancels queries is incredi... by xmcqdpt2 on Monday March 23, 2026 @09:34AM (#47489333)
Zero trust security which is becoming increasingly common is based on removing the internal / external network dichotomy entirely. Everything should be assumed to be reachable from the open internet (so SSO, OIDC everywhere.)
Re:The way CTRL-C in Postgres CLI cancels queries is incredi... by gruez on Monday March 23, 2026 @09:32AM (#47489317)
>I've never had to connect to PostGres in an adversarial environment.

heroku's postgres database service still exposes itself on the public internet.

Re:The way CTRL-C in Postgres CLI cancels queries is incredi... by megous on Monday March 23, 2026 @12:10PM (#47491455)
cancel key is arbitrary sized

https://www.postgresql.org/docs/current/protocol-message-for... / BackendKeyData

Re:The way CTRL-C in Postgres CLI cancels queries is incredi... by conradludgate on Tuesday March 24, 2026 @03:29AM (#47499545)
This is new in postgres 18/protocol 3.2. libpq still defaults to protocol 3.0 and many client drivers don't have support for protocol 3.2
Re:The way CTRL-C in Postgres CLI cancels queries is incredi... by tensegrist on Monday March 23, 2026 @09:13AM (#47489061)
is sed s/—/--/ the new meta
Re:The way CTRL-C in Postgres CLI cancels queries is incredi... by shilgapira on Monday March 23, 2026 @09:30AM (#47489301)
offtopic, but it's interesting how large of a discrepancy there is between the length of your comment and how much time i'd have to spend explaining background info to a non-programmer to get them to understand why this is funny
Re:The way CTRL-C in Postgres CLI cancels queries is incredi... by pas on Monday March 23, 2026 @12:00PM (#47491293)
why is it funny? it seems like a sincere question
Re:The way CTRL-C in Postgres CLI cancels queries is incredi... by petit_robert on Monday March 23, 2026 @06:42PM (#47496137)
The way it's written is funny, I find. But I'm a programmer...

And as GP wrote, it would take a substantial amount of time to explain to a normie (infinite I'd say, but let's not despair).

Re:The way CTRL-C in Postgres CLI cancels queries is incredi... by arvyy on Monday March 23, 2026 @09:24AM (#47489202)
hardly new, I've used it before advent of llm popularity, and I wasn't alone
Re:The way CTRL-C in Postgres CLI cancels queries is incredi... by mattkrause on Monday March 23, 2026 @10:07AM (#47489748)
It should be THREE hyphens for an em-dash!
Re:The way CTRL-C in Postgres CLI cancels queries is incredi... by kelnos on Monday March 23, 2026 @05:38PM (#47495450)
In theory, yes, endash would be "--" and emdash would be "---", but oof, the three hyphens looks like way too much in normal text. So I've always used "--".
Re:The way CTRL-C in Postgres CLI cancels queries is incredi... by paulddraper on Monday March 23, 2026 @10:00AM (#47489682)
I've always used it.

My keyboard has -.

Re:The way CTRL-C in Postgres CLI cancels queries is incredi... by kelnos on Monday March 23, 2026 @05:34PM (#47495412)
I have used "--" as a lazy-man's emdash for decades at this point. Once I heard that people started assuming text that uses emdashes was written by an LLM I got worried that people were going to think that I'm an LLM, but then I realized the LLMs use the real unicode emdash character, while I just use two regular ASCII-zone hyphens. Whew.

(Also I just learned that ASCII 0x2d/unicode U+002D is more properly called a "hyphen" [well, "HYPHEN-MINUS"], not a "dash".)

Re:The way CTRL-C in Postgres CLI cancels queries is incredi... by tensegrist on Tuesday March 24, 2026 @11:58AM (#47504620)
well, that was my point, that people have seemingly begun replacing — with -- or --- in llm-generated comments recently

this is maybe the fifth time i've seen this happen on hn in the last few weeks