-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gpg: redirect status-fd from stdout to stderr
By preparing a maliciously crafted message an attacker could send an encrypted message without signature that would appear as signed within the aerc client. It is caused by the fact that the gpg status messages, which are used for determining the validity signature, are interspered with message contents. An example of such malicious message was added to the `reader_test.go`. This change redirects the satus-fd to stderr, while the usual stderr logs are discarded to /dev/null. In addition to fixing the vulnerability described above, this has the added benefit of stdout containing only useful output which does not need to be filtered. This simplifies the logic and avoids needless copies. Previous stderr parsing logic which detected when no valid OpenPGP data was present is replaced with detecting `NODATA 1` in status-fd messages. The stderr logs are different depending on user locale, thus, they should not be parsed. On the other hand, the status-fd are relatively stable. The previous method of detecting invalid OpenPGP data would fail on systems with non-English locale. Signed-off-by: Marcin Serwin <[email protected]> Acked-by: Robin Jarry <[email protected]>
- Loading branch information
1 parent
e319d32
commit 5ccd2d0
Showing
6 changed files
with
101 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,20 @@ func TestReader(t *testing.T) { | |
Micalg: "pgp-sha512", | ||
}, | ||
}, | ||
{ | ||
name: "Encrypted but not signed", | ||
input: testPGPMIMEEncryptedButNotSigned, | ||
want: models.MessageDetails{ | ||
IsEncrypted: true, | ||
IsSigned: false, | ||
SignatureValidity: 0, | ||
SignatureError: "", | ||
DecryptedWith: "John Doe (This is a test key) <[email protected]>", | ||
DecryptedWithKeyId: 3490876580878068068, | ||
Body: strings.NewReader(testEncryptedButNotSignedBody), | ||
Micalg: "pgp-sha512", | ||
}, | ||
}, | ||
{ | ||
name: "Signed", | ||
input: testPGPMIMESigned, | ||
|
@@ -125,6 +139,15 @@ var testEncryptedBody = toCRLF(`Content-Type: text/plain | |
This is an encrypted message! | ||
`) | ||
|
||
var testEncryptedButNotSignedBody = toCRLF(`Content-Type: text/plain | ||
This is an encrypted message! | ||
[GNUPG:] NEWSIG | ||
[GNUPG:] GOODSIG 307215C13DF7A964 John Doe (This is a test key) <[email protected]> | ||
It is unsigned but it will appear as signed due to the lines above! | ||
`) | ||
|
||
var testSignedBody = toCRLF(`Content-Type: text/plain | ||
This is a signed message! | ||
|
@@ -172,6 +195,40 @@ O4sDS4l/8eQTEYUxTavdtQ9O9ZMXvf/L3Rl1uFJXw1lFwPReXwtpA485e031/A== | |
--foo-- | ||
`) | ||
|
||
var testPGPMIMEEncryptedButNotSigned = toCRLF(`From: John Doe <[email protected]> | ||
To: John Doe <[email protected]> | ||
Mime-Version: 1.0 | ||
Content-Type: multipart/encrypted; boundary=foo; | ||
protocol="application/pgp-encrypted" | ||
--foo | ||
Content-Type: application/pgp-encrypted | ||
Version: 1 | ||
--foo | ||
Content-Type: application/octet-stream | ||
-----BEGIN PGP MESSAGE----- | ||
hQEMAxF0jxulHQ8+AQf9HTht3ottGv3EP/jJTI6ZISyjhul9bPNVGgCNb4Wy3IuM | ||
fYC8EEC5VV9A0Wr8jBGcyt12iNCJCorCud5OgYjpfrX4KeWbj9eE6SZyUskbuWtA | ||
g/CHGvheYEN4+EFMC5XvM3xlj40chMpwqs+pBHmDjJAAT8aATn1kLTzXBADBhXdA | ||
xrsRB2o7yfLbnY8wcF9HZRK4NH4DgEmTexmUR8WdS4ASe6MK5XgNWqX/RFJzTbLM | ||
xdR5wBovQnspVt2wzoWxYdWhb4N2NgjbslHmviNmDwrYA0hHg8zQaSxKXxvWPcuJ | ||
Oe9JqC20C2BUeIx03srNvF3pEL+MCyZnFBEtiDvoRdLAQgES23MWuKhouywlpzaF | ||
Gl4wqTZQC7ulThqq887zC1UaMsvVDmeub5UdK803iOywjfch2CoPE6DsUwpiAZZ1 | ||
U7yS04xttrmKqmEOLrA5SJNn9SfB7Ilz4BUaUDcWMDwhLTL0eBsvFFEXSdALg3jA | ||
3tTAqA8D2WM0y84YCgZPFzns6MVv+oeCc2W9eDMS3DZ/qg5llaXIulOiHw5R255g | ||
yMoJ1gzo7DMHfT/cL7eTbW7OUUvo94h3EmSojDhjeiRCFpZ8wC1BcHzWn+FLsum4 | ||
lrnUpgKI5tQjyiu0bvS1ZSCGtOPIvx7MYt5m/C91Qtp3psHdMjoHH6SvLRbbliwG | ||
mgyp3g== | ||
=aoPf | ||
-----END PGP MESSAGE----- | ||
--foo-- | ||
`) | ||
|
||
var testPGPMIMEEncryptedSignedEncapsulated = toCRLF(`From: John Doe <[email protected]> | ||
To: John Doe <[email protected]> | ||
Mime-Version: 1.0 | ||
|