[GH-ISSUE #1941] double free in ssh2john #1293

Closed
opened 2026-10-14 03:43:00 +07:00 by bsakaguchi · 4 comments
Owner

Originally created by @magnumripper on GitHub (Dec 8, 2015).
Original GitHub issue: https://github.com/openwall/john/issues/1941

Originally assigned to: @kholia on GitHub.

Reported by Hanno Böck

There is a double free error in ssh2john if you run it against a file
that contains two ssl certificate blocks.

Just take a random certificate, add it twice to a file:

cat test.crt test.crt > out.crt

and run

ssh2john out.crt

Seems there is a loop that is freeing all openssl objects at the end of
the loop and then reusing the same objects and freeing them for every
iteration of the loop.

Originally created by @magnumripper on GitHub (Dec 8, 2015). Original GitHub issue: https://github.com/openwall/john/issues/1941 Originally assigned to: @kholia on GitHub. Reported by [Hanno Böck](http://www.openwall.com/lists/john-dev/2015/12/08/1) There is a double free error in ssh2john if you run it against a file that contains two ssl certificate blocks. Just take a random certificate, add it twice to a file: ``` cat test.crt test.crt > out.crt ``` and run ``` ssh2john out.crt ``` Seems there is a loop that is freeing all openssl objects at the end of the loop and then reusing the same objects and freeing them for every iteration of the loop.
Author
Owner

@kholia commented on GitHub (Dec 8, 2015):

I am thinking of removing ssh2john.c and ssh_fmt_plug.c. The code is simply terrible.

ssh-ng and pem formats are better for doing this stuff.

<!-- gh-comment-id:163060450 --> @kholia commented on GitHub (Dec 8, 2015): I am thinking of removing ssh2john.c and ssh_fmt_plug.c. The code is simply terrible. `ssh-ng` and `pem` formats are better for doing this stuff.
Author
Owner

@magnumripper commented on GitHub (Dec 8, 2015):

Is there any functionality that only the non-ng format can provide?

<!-- gh-comment-id:163060994 --> @magnumripper commented on GitHub (Dec 8, 2015): Is there any functionality that only the non-ng format can provide?
Author
Owner

@kholia commented on GitHub (Dec 9, 2015):

ssh can handle PEM files which use AES. Our new pem format can be extended to do that as well.

<!-- gh-comment-id:163061464 --> @kholia commented on GitHub (Dec 9, 2015): `ssh` can handle PEM files which use AES. Our new `pem` format can be extended to do that as well.
Author
Owner

@magnumripper commented on GitHub (Dec 21, 2015):

This is sort of fixed (deprecating the format) but not merged yet. Changing label accordingly.

<!-- gh-comment-id:166418673 --> @magnumripper commented on GitHub (Dec 21, 2015): This is sort of fixed (deprecating the format) but not merged yet. Changing label accordingly.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
openwall/john#1293
No description provided.