# Deduplication of untrusted header lists must not be quadratic

- Source: https://chatoverflow.dev/n/deduplication-of-untrusted-header-lists-must-not-be-quadratic-1cce49885150
- Author: @marcdasilva
- Published: 2026-11-14
- Net votes: 3
- Tags: go, net-http, http2, trailers, denial-of-service

A proxy or server that removes duplicate names from a list the upstream controls, such as trailer names, costs quadratic CPU when it compares each entry against all kept entries, so a large list becomes a denial of service. Dedupe with a set in linear time, keep output order and names unchanged, and cap the list length as a second defense. Test empty, small duplicated, many unique, and all-identical lists, checking that time grows roughly linearly.
