Skip to content

Stop the obfuscation marker being emitted twice - #33

Merged
nGoline merged 1 commit into
mainfrom
fix/duplicate-obfuscation-marker
Sep 8, 2026
Merged

nGoline merged 1 commit into
mainfrom
fix/duplicate-obfuscation-marker

Conversation

@nGoline

@nGoline nGoline commented Sep 8, 2026

Copy link
Copy Markdown
Owner

An obfuscated message began and ended with the marker repeated:

00023CD100023CD1wV4DTmkMQQGcaxcSAQdANo1t8...=x9Yz00023CD100023CD1

Cause

Not every line break — only blank lines. obfuscateMarkers replaced them with the marker alongside the armor header and footer, and armored output happens to carry a blank line immediately after the Version: header and another at the end, both sitting next to a real marker:

Line Rule Emits
-----BEGIN PGP MESSAGE----- armor header 00023CD1
Version: BCPG v1.81 Version:/Comment: nothing
(blank) line.isBlank() 00023CD1 ←
wV4DTmk... everything else the line itself
-----END PGP MESSAGE----- armor footer 00023CD1
(blank) line.isBlank() 00023CD1 ←

Ordinary lines are joined with no separator, so the body was never affected — only the two ends.

Why it is worth fixing rather than tolerating

The setting's own description is "make messages harder to detect". A doubled sixteen-character hex run is a more distinctive signature than a single eight-character one, so the duplication worked against the feature it belonged to.

The fix

Blank lines are dropped, like the Version: header immediately above them. Nothing depended on them being marked: every use of the marker either tests for it at the start of a message or strips every occurrence, and deobfuscation discards all newlines and re-chunks the base64 from scratch, so the blank line's structural role is rebuilt rather than preserved.

Backward compatibility

Messages already sent carry the doubled markers and cannot be recalled. Deobfuscation removes every occurrence, so they still work — and there is a test pinning that, because it would be easy to tidy the deobfuscator later and silently break every message sent before this release.

Tests

Seven, covering what the feature emits as well as whether it round trips:

  • the marker is not repeated back to back
  • exactly one marker at each end
  • no -----BEGIN, -----END or BCPG version string survives
  • the payload and its checksum are untouched
  • obfuscate → deobfuscate returns armor whose body matches byte for byte
  • messages in the old doubled format still deobfuscate
  • an obfuscated message is still recognised as one, since decryptMessage and the notification listener both detect by leading marker

Mutation-checked: restoring the old behaviour fails two of them. 63 tests total, lint clean.

obfuscateMarkers becomes internal + @VisibleForTesting, matching deobfuscateMarkers.

Note

No version bump here — that goes in the release PR when you cut the next version, same as 0.4 and 0.5.

An obfuscated message began and ended with the marker repeated:

    00023CD100023CD1wV4DTmk...=x9Yz00023CD100023CD1

Blank lines were being replaced with the marker alongside the armor header and
footer, and armored output carries one blank line after the version header and
another at the end. So each real marker was followed, or preceded, by a second.
Ordinary lines are joined with no separator, so the body was never affected —
only the two ends.

This is not only untidy. The setting exists to make a message harder to
recognise as PGP, and a doubled sixteen-character hex run is a more distinctive
signature than a single one, so the duplication worked against the feature it
belonged to.

Blank lines are now dropped, like the version header immediately above them.
Nothing depended on them: every use of the marker either tests for it at the
start of a message or strips every occurrence, and deobfuscation discards all
newlines and re-chunks the base64 from scratch.

Messages already sent carry the doubled markers and cannot be recalled, so
there is a test pinning that they still deobfuscate.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@nGoline
nGoline merged commit f0d1953 into main Sep 8, 2026
2 checks passed
@nGoline
nGoline deleted the fix/duplicate-obfuscation-marker branch September 8, 2026 13:22
@nGoline nGoline mentioned this pull request Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant