gchq / gchq/CyberChef

Bug report: Incorrect railfence decryption

Open
#1,108 0 comments 1 reaction 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
35.8k
Forks
4.1k
Avg merge
2d 26m
Merged PRs (30d)
33

Description

**Describe the bug**
RailFence decryption is incorrectly adding some trailing spaces (padding?) before decryption which is resulting in incorrect plaintext.

**To Reproduce**
Steps to reproduce the behaviour or a link to the recipe / input used to cause the bug:

1. Go to cyberchef
2. Input cipher text : `/1E11v1 ee1smr1hoyaosF2u r/lpisdled enh`
3. Select `RailFence` cipher with key: `11` and
4. Observe plain text: `/1era2/sdh dluo1e11v1hs ple neirFos1E my`

**Expected behaviour**
Plaintext should be: `/EveryFriends/2a111111 should help some`
It can be verified on [this][working] site.

**Additional context**
It can be observed on the [same][working] site that railfence of
ciphertext: `/1E11v1 ee1smr1hoyaosF2u r/lpisdled enh ` (with 5 trailing spaces)
results in plaintext: `/1era2/sdh dluo1e11v1hs ple neirFos1E my`
which matches the cyberchef response.

It appears as if CyberChef is padding the input ciphertext with `key - len%key` i.e. `11 - 39%11 = 5` spaces characters to meet the nearest _block size of 11_.

[working]: https://www.boxentriq.com/code-breaking/rail-fence-cipher

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.