Skip to content

Commit faa47f9

Browse files
committed
ConvertToSecureStringAsPlainText
1 parent 2898910 commit faa47f9

File tree

4 files changed

+48
-2
lines changed

4 files changed

+48
-2
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<!DOCTYPE qhelp PUBLIC
2+
"-//Semmle//qhelp//EN"
3+
"qhelp.dtd">
4+
<qhelp>
5+
<overview>
6+
<p>The use of the AsPlainText parameter with the ConvertTo-SecureString command can expose secure information.</p>
7+
8+
</overview>
9+
<recommendation>
10+
<p>
11+
If you do need an ability to retrieve the password from somewhere without prompting the user, consider using the <a href="https://www.powershellgallery.com/packages/Microsoft.PowerShell.SecretStore">SecretStore</a> module from the PowerShell Gallery.
12+
</p>
13+
</recommendation>
14+
<references>
15+
16+
<li>
17+
OWASP:
18+
<a href="https://www.owasp.org/index.php/Command_Injection">Command Injection</a>.
19+
</li>
20+
<li>
21+
PSScriptAnalyzer:
22+
<a href="https://learn.microsoft.com/en-us/powershell/utility-modules/psscriptanalyzer/rules/avoidusingconverttosecurestringwithplaintext?view=ps-modules">AvoidUsingConvertToSecureStringWithPlainText</a>.
23+
</li>
24+
<!-- LocalWords: CWE untrusted unsanitized Runtime
25+
-->
26+
27+
</references>
28+
</qhelp>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* @name Use of the AsPlainText parameter in ConvertTo-SecureString
3+
* @description Do not use the AsPlainText parameter in ConvertTo-SecureString
4+
* @kind problem
5+
* @problem.severity error
6+
* @security-severity 7.0
7+
* @precision high
8+
* @id powershell/microsoft/public/convert-to-securestring-as-plaintext
9+
* @tags correctness
10+
* security
11+
*/
12+
13+
import powershell
14+
15+
from CmdCall c
16+
where
17+
c.getName() = "ConvertTo-SecureString" and
18+
c.hasNamedArgument("asplaintext")
19+
select c, "Use of AsPlainText parameter in ConvertTo-SecureString call"

powershell/ql/src/experimental/UseOfReservedCmdletChar.ql

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
* @id powershell/microsoft/public/reserved-characters-in-function-name
99
* @tags correctness
1010
* security
11-
* external/cwe/cwe-078
12-
* external/cwe/cwe-088
1311
*/
1412

1513
import powershell
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
| test.ps1:2:19:2:79 | Call to ConvertTo-SecureString | Use of AsPlainText parameter in ConvertTo-SecureString call |

0 commit comments

Comments
 (0)