Adversaries may execute their own malicious payloads by hijacking the Registry entries used by services. Adversaries may use flaws in the permissions for Registry keys related to services to redirect from the originally specified executable to one that they control, in order to launch their own code when a service starts. Windows stores local service configuration information in the Registry under <code>HKLM\SYSTEM\CurrentControlSet\Services</code>. The information stored under a service's Registry keys can be manipulated to modify a service's execution parameters through tools such as the service controller, sc.exe,  [PowerShell](https://attack.mitre.org/techniques/T1059/001), or [Reg](https://attack.mitre.org/software/S0075). Access to Registry keys is controlled through access control lists and user permissions. (Citation: Registry Key Security)(Citation: malware_hides_service)

If the permissions for users and groups are not properly set and allow access to the Registry keys for a service, adversaries may change the service's binPath/ImagePath to point to a different executable under their control. When the service starts or is restarted, then the adversary-controlled program will execute, allowing the adversary to establish persistence and/or privilege escalation to the account context the service is set to execute under (local/domain account, SYSTEM, LocalService, or NetworkService).

Adversaries may also alter other Registry keys in the service’s Registry tree. For example, the <code>FailureCommand</code> key may be changed so that the service is executed in an elevated context anytime the service fails or is intentionally corrupted.(Citation: Kansa Service related collectors)(Citation: Tweet Registry Perms Weakness)

The <code>Performance</code> key contains the name of a driver service's performance DLL and the names of several exported functions in the DLL.(Citation: microsoft_services_registry_tree) If the <code>Performance</code> key is not already present and if an adversary-controlled user has the <code>Create Subkey</code> permission, adversaries may create the <code>Performance</code> key in the service’s Registry tree to point to a malicious DLL.(Citation: insecure_reg_perms)

Adversaries may also add the <code>Parameters</code> key, which stores driver-specific data, or other custom subkeys for their malicious services to establish persistence or enable other malicious activities.(Citation: microsoft_services_registry_tree)(Citation: troj_zegost) Additionally, If adversaries launch their malicious services using svchost.exe, the service’s file may be identified using <code>HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\servicename\Parameters\ServiceDll</code>.(Citation: malware_hides_service)
Services Registry Permissions Weakness
source_name: mitre-attack  url: https://attack.mitre.org/techniques/T1574/011  external_id: T1574.011     source_name: Tweet Registry Perms Weakness  description: @r0wdy_. (2017, November 30). Service Recovery Parameters. Retrieved April 9, 2018.  url: https://twitter.com/r0wdy_/status/936365549553991680     source_name: insecure_reg_perms  description: Clément Labro. (2020, November 12). Windows RpcEptMapper Service Insecure Registry Permissions EoP. Retrieved August 25, 2021.  url: https://itm4n.github.io/windows-registry-rpceptmapper-eop/     source_name: Kansa Service related collectors  description: Hull, D.. (2014, May 3). Kansa: Service related collectors and analysis. Retrieved October 10, 2019.  url: https://trustedsignal.blogspot.com/2014/05/kansa-service-related-collectors-and.html     source_name: malware_hides_service  description: Lawrence Abrams. (2004, September 10). How Malware hides and is installed as a Service. Retrieved August 30, 2021.  url: https://www.bleepingcomputer.com/tutorials/how-malware-hides-as-a-service/     source_name: Autoruns for Windows  description: Mark Russinovich. (2019, June 28). Autoruns for Windows v13.96. Retrieved March 13, 2020.  url: https://docs.microsoft.com/en-us/sysinternals/downloads/autoruns     source_name: Registry Key Security  description: Microsoft. (2018, May 31). Registry Key Security and Access Rights. Retrieved March 16, 2017.  url: https://docs.microsoft.com/en-us/windows/win32/sysinfo/registry-key-security-and-access-rights?redirectedfrom=MSDN     source_name: microsoft_services_registry_tree  description: Microsoft. (2021, August 5). HKLM\SYSTEM\CurrentControlSet\Services Registry Tree. Retrieved August 25, 2021.  url: https://docs.microsoft.com/en-us/windows-hardware/drivers/install/hklm-system-currentcontrolset-services-registry-tree     source_name: troj_zegost  description: Trend Micro. (2012, October 9). TROJ_ZEGOST. Retrieved September 2, 2021.  url: https://www.trendmicro.com/vinfo/us/threat-encyclopedia/malware/troj_zegost     