Powershell Usage
Depois de ler e participar passivamente de tantos blogs e fóruns de cibersegurança, porque não fazer uma publicação também?
[PT-BR]
Neste último fim de semana estive vasculhando um pouco os sites blogs de cibersegurança e me deparei com essa CVE-2025–30406. De cara, pensei: tantas formas que poderíamos evitar os impactos dessa vulnerabilidade, e uma de nossas melhores opções é simples e muitas vezes menosprezada — o Hardening (ou Application Control, a depender das configurações).
Controlar o uso do Powershell dentro da organização é uma forma de Hardening e com ele nos pouparíamos de muitas dores de cabeça.
Por mais que essa CVE seja de um software bem específico, a forma de exploração é como divulgada: “leveraging it to download and side load a DLL using an encoded Powershell script”. Ou seja, usando comandos Powershell. Note que essa vulnerabilidade em questão possibilita execuções de comandos arbitrários.
Vamos aos insights…
Provocações
- Por qual motivo um usuário do RH, administrativo ou até mesmo do financeiro, precisa de acesso ao Powershell em sua máquina?
- Você prefere ter que fazer uma análise forense pós-incidente ou simplesmente evitá-la?
Métodos
- Restrição via GPO — Software Restrictions
- Powershell script Signing
Na Prática
Restrição via GPO — Software Restrictions
Podemos bloquear o uso do Powershell para todos os usuários (com a opção de permitir o uso por administradores) através de GPOs. Assim como demonstro a seguir:
- Antes da configuração de Software Restrictions — consigo abrir o Powershell
- Limito o uso do Powershell dentro das políticas de configurações do Windows para Usuários
- Também faço o ‘delegate’ para o meu grupo de SysAdmins permitindo o uso para eles
Isto já é suficiente para controlar o uso da CLI. No entanto, uma pessoa mal-intencionada ainda é capaz de mover o executável de diretório e ‘bypassar’ nossa configuração. Para evitar o meu último comentário, podemos, além da regra por ‘Path’, criar por Hash do binário.
Powershell script Signing
A segunda alternativa (muito eficaz) seria permitir que apenas scripts reconhecidos, ou seja, assinados por nós, administradores, sejam executados dentro da máquina. Caso contrário, a Execution Policy irá bloquear a execução.
Existe um padrão no Powershell que bloqueia a execução de scripts não assinados por uma entidade confiável. Isto acontece quando a política de execução está como “RemoteSigned”. Podemos confirmar com este comandoGet-ExecutionPolicy , e forçar esta configuração com:
Set-ExecutionPolicy RemoteSigned. Para saber melhor como criar um certificado e assinar para este cenário do Powershell, nada melhor que uma documentação, não é? Vide Microsoft documentation.
Logging
Uma boa prática é implementar a auditoria sobre o uso do Powershell. Dessa forma, conseguimos saber como e quem está usando essa poderosa ferramenta, além de ter noção do impacto em cenários adversos.
Segue o caminho exato da configuração:
GPO — Administrative Templates → Windows Components → Windows Powershell
Obs.:
- Na grande maioria dos ambientes, o uso de Script Block Encoded não é um bom sinal. Vale a pena monitorar o seu uso. Inclusive bloquear o usuário que executou como isolar a máquina origem da rede como forma de resposta automatizada.
Conclusão
Mesmo sem ferramentas de terceiros, conseguimos evitar grandes impactos com auxílio de Hardening! Isto significa que é possível conter o risco de forma eficiente — com pouco esforço e baixo custo.
Get Pedro Ribeiro’s stories in your inbox
Join Medium for free to get updates from this writer.
[EN-US]
This past weekend, while browsing through some cybersecurity blogs, I came across CVE-2025–30406. Right away, I thought: there are so many ways we could reduce the impact of this vulnerability, and one of the best options is actually quite simple — yet often overlooked — Hardening (or Application Control, depending on the setup).
Controlling the use of Powershell within the organization is a form of Hardening — and one that could save us from a lot of headaches.
Although this CVE targets a specific software, the exploitation method is straightforward: leveraging it to download and side-load a DLL using an encoded Powershell script. In other words, it relies on Powershell commands. What makes this vulnerability critical is that it allows arbitrary command execution.
Now, let’s get into the insights…
Provocation
- Why would an HR, administrative, or even finance user need access to Powershell on their machine in the first place?
- Would you rather go through a full forensic investigation after an incident — or simply prevent it from happening?
Methods
- Restriction via GPO — Software Restrictions
- Powershell Script Signing
In Practice
Restriction via GPO — Software Restrictions
We can block the use of Powershell for all users (excluding its use by administrators) using GPOs. Check how:
- Before configuring Software Restrictions: Powershell opens without any issues.
- Applying the restriction: I restrict the use of Powershell within the Windows Settings policies for Users.
- I delegate permissions to my SysAdmins group, allowing them to use the tool.
This is already sufficient to control the use of the CLI. However, a malicious actor could still move the executable to a different directory and bypass our configuration. To prevent this, we can complement the ‘Path’ rule with a rule based on the binary’s Hash, which complements the other.
Powershell Script Signing
A second (highly effective) alternative is to allow only recognized scripts — those signed by us, the administrators — to run on the machines. Otherwise, the Execution Policy will block the execution.
By default, Powershell can be configured to block the execution of scripts not signed by a trusted authority. This happens when the execution policy is set to “RemoteSigned”. We can check the current setting with the Get-ExecutionPolicy command and enforce this configuration with: Set-ExecutionPolicy RemoteSigned
To learn more about creating a certificate and signing scripts for Powershell, the official documentation is the best place to consult. So take a look at Microsoft documentation.
Logging
A best practice is to implement auditing for Powershell usage. This way, we can track how and who is using this powerful tool, and understand the impact in potential breach scenarios.
The exact path to enable logging via Group Policy is:
GPO → Administrative Templates → Windows Components → Windows Powershell
Note:
- In the vast majority of environments, the use of encoded script blocks is not a good sign. It’s worth closely monitoring this activity. In some cases, even blocking the user who executed it and isolating the source machine from the network can be necessary automated response measures.
Conclusion
Even without third-party tools, we can prevent major impacts with the help of Hardening! This shows that it’s possible to contain risk effectively — with minimal effort and low cost.







