---
title: "Ctrl-C in psql gives me the heebie-jeebies"
description: "Postgres cancels queries via a separate CancelRequest connection identified only by a process ID and secret key, and psql still sends it in plaintext even when the main connection uses strict TLS, because libpq's encrypted cancel functions (added in Postgres 17) aren't signal-safe for psql yet."
url: "https://swe.quest/articles/ctrl-c-in-psql-gives-me-the-heebie-jeebies-e2b63a9641ee547d"
canonical: "https://neon.com/blog/ctrl-c-in-psql-gives-me-the-heebie-jeebies"
source: "Neon"
published: "2026-03-05"
difficulty: "medium"
kind: "Deep dive"
reading_minutes: 6
tags: ["postgres","networking","security","cryptography"]
---

# Ctrl-C in psql gives me the heebie-jeebies

A post on [Neon](https://swe.quest/sources/neon.md), published 2026-03-05, 6 min read, Deep dive. Original: [https://neon.com/blog/ctrl-c-in-psql-gives-me-the-heebie-jeebies](https://neon.com/blog/ctrl-c-in-psql-gives-me-the-heebie-jeebies)

## Summary

Postgres cancels queries via a separate CancelRequest connection identified only by a process ID and secret key, and psql still sends it in plaintext even when the main connection uses strict TLS, because libpq's encrypted cancel functions (added in Postgres 17) aren't signal-safe for psql yet. That exposes a denial-of-service risk: anyone observing traffic can replay the request to cancel every future query on the connection, even with protocol 3.2's longer keys. The missing TLS also means no SNI, which broke cancellation in the Elephantshark proxy until v0.3 added a map from (process ID, secret key) to destination host. Recommended mitigations: Postgres 18 with min\_protocol\_version=3.2, a VPN, avoiding Ctrl-C in psql, and checking whether other drivers encrypt cancels.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [Networking](https://swe.quest/tags/networking.md) (Infrastructure)
- [Security](https://swe.quest/tags/security.md) (Security)
- [Cryptography](https://swe.quest/tags/cryptography.md) (Security)

## Prerequisites

- Postgres wire protocol basics ([easy posts on PostgreSQL](https://swe.quest/tags/postgres.md?difficulty=easy))
- TLS and SNI ([easy posts on Cryptography](https://swe.quest/tags/cryptography.md?difficulty=easy))
- psql and libpq

## Keywords

psql, libpq, CancelRequest, Elephantshark, SNI, Postgres protocol 3.2, Neon

## Related posts

- [Shipping psql without psql: a pure-TypeScript Postgres client in neonctl](https://swe.quest/articles/shipping-psql-without-psql-a-pure-typescript-postgres-client-in-neonctl-621e0ac130c536d1.md): Neon · 2026-06-12 · Medium · 7 min read · PostgreSQL, TypeScript, Testing, AI for coding, Developer tools
  neonctl now embeds a pure-TypeScript reimplementation of psql that activates when no native psql is on the PATH.
- [What's New in pg\_clickhouse v0.3.2: Postgres 19, TLS, Regex, and Memory](https://swe.quest/articles/what-s-new-in-pg-clickhouse-v0-3-2-postgres-19-tls-regex-and-memory-db831637f7730c4c.md): ClickHouse · 2026-06-23 · Medium · 2 min read · PostgreSQL, Analytics & OLAP, Databases
  pg\_clickhouse v0.3.2, the Postgres extension for querying ClickHouse, adds support for PostgreSQL 19 Beta1 and needs no restart or ALTER EXTENSION UPDATE.
- [MITM attacks are easier to avoid with psql (Postgres) 16](https://swe.quest/articles/mitm-attacks-are-easier-to-avoid-with-psql-postgres-16-ea4ca88c3d78880f.md): Neon · 2023-10-05 · Medium · 8 min read · PostgreSQL, Cryptography, Security, Identity & auth
  Postgres 16's psql adds \`sslrootcert=system\`, which uses the OS's trusted CA store and implies \`sslmode=verify-full\`.
- [Quicker serverless Postgres connections](https://swe.quest/articles/quicker-serverless-postgres-connections-7a37a1071edd4362.md): Neon · 2023-03-28 · Medium · 8 min read · PostgreSQL, Networking, Serverless, Performance engineering, Cryptography
  Neon cut the network round-trips needed to get a first query result from its WebSocket-based serverless Postgres driver from nine to four.
- [Incident Report: April 23rd, 2025](https://swe.quest/articles/incident-report-april-23rd-2025-f0e6e4113e1badba.md): Railway · 2025-04-23 · Medium · 4 min read · Incidents & postmortems, Resilience, PostgreSQL, Networking, Caching
  A Google Cloud SQL maintenance window took Railway's networking control plane Postgres read replica offline for about 10 minutes, destabilizing edge, private networking and TCP proxy traffic across all regions, worst in Asia.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
