Skip to content

Commit 74c8f98

Browse files
Insert the end-of-options marker before operation arguments.
This marker stops the parsing of additional options during external calls to GPG. This behavior is unintended but its security impact is dependent on the environment and the GPG version in use.
1 parent 44b6f70 commit 74c8f98

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

Crypt/GPG.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ public function deletePublicKey($keyId)
427427
);
428428
}
429429

430-
$operation = '--delete-key ' . escapeshellarg($fingerprint);
430+
$operation = '--delete-key -- ' . escapeshellarg($fingerprint);
431431
$arguments = array(
432432
'--batch',
433433
'--yes'
@@ -474,7 +474,7 @@ public function deletePrivateKey($keyId)
474474
);
475475
}
476476

477-
$operation = '--delete-secret-key ' . escapeshellarg($fingerprint);
477+
$operation = '--delete-secret-key -- ' . escapeshellarg($fingerprint);
478478
$arguments = array(
479479
'--batch',
480480
'--yes'
@@ -546,7 +546,7 @@ public function getKeys($keyId = '')
546546
public function getFingerprint($keyId, $format = self::FORMAT_NONE)
547547
{
548548
$output = '';
549-
$operation = '--list-keys ' . escapeshellarg($keyId);
549+
$operation = '--list-keys -- ' . escapeshellarg($keyId);
550550
$arguments = array(
551551
'--with-colons',
552552
'--with-fingerprint'
@@ -1464,7 +1464,7 @@ protected function _exportKey($keyId, $armor = true, $private = false)
14641464

14651465
$keyData = '';
14661466
$operation = $private ? '--export-secret-keys' : '--export';
1467-
$operation .= ' ' . escapeshellarg($fingerprint);
1467+
$operation .= ' -- ' . escapeshellarg($fingerprint);
14681468
$arguments = $armor ? array('--armor') : array();
14691469

14701470
$this->engine->reset();

Crypt/GPGAbstract.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ protected function _getKeys($keyId = '')
334334
if ($keyId == '') {
335335
$operation = '--list-secret-keys';
336336
} else {
337-
$operation = '--utf8-strings --list-secret-keys ' . escapeshellarg($keyId);
337+
$operation = '--utf8-strings --list-secret-keys -- ' . escapeshellarg($keyId);
338338
}
339339

340340
// According to The file 'doc/DETAILS' in the GnuPG distribution, using
@@ -366,7 +366,7 @@ protected function _getKeys($keyId = '')
366366
if ($keyId == '') {
367367
$operation = '--list-public-keys';
368368
} else {
369-
$operation = '--utf8-strings --list-public-keys ' . escapeshellarg($keyId);
369+
$operation = '--utf8-strings --list-public-keys -- ' . escapeshellarg($keyId);
370370
}
371371

372372
$output = '';

0 commit comments

Comments
 (0)