The issue was happening in Ghostty, iTerm2, and Terminal.app. It happened by (a) pasting directly into the terminal prompt with Command-V, (b) using `pbpaste` in any way (like piping it into `wc -c`), or (c) pasting into an editor like Neovim with Command-V.
It doesn't happen with any other file I tested it with. It also doesn't happen if I try to paste into another app, like Visual Studio Code, TextEdit, or IntelliJ IDEA itself.
Nothing is inherently wrong with the binary/text content of the file. It's all ASCII characters.
I guess the first step would be to disable those “AV products” to see whether they affect the issue (aside: I would already find “AV product” too much, but productS?). That way, you know who to report the issue to.
Next, reading your next comment, would be try and make the string shorter to try and find the shirted example.
Both our Mac IT manager and I are thinking that it's the AV engine (Microsoft Defender) seeing fragments of YAML in the PSI tree and then blowing up after trying to parse the next line (which is not a truly valid YAML tree, it's a YAML tree with all the semantic details produced by IntelliJ). That in and of itself shouldn't be an issue, but I guess they weren't expecting random fragments of YAML to be copied and pasted.
We're still not sure why it only triggers in terminal emulators, though. That one is a total mystery.