SlideShare a Scribd company logo
1 of 21
Download to read offline
Bypassing Windows services
        protections



       Cesar Cerrudo
         Argeniss
Who am I?
• Argeniss Founder and CEO (23 people company)
• I have been working on security for +9 years
• I have found and helped to fix hundreds of
  vulnerabilities in software such as MS Windows,
  MS SQL Server, Oracle Database Server, IBM
  DB2, and many more...
• +50 vulnerabilities found on MS products (+20
  on Windows operating systems)
• I have researched and created novel attacks and
  exploitation techniques
Agenda
• Introduction
• What is impersonation and what are tokens?
• Windows 7, Vista and 2008 services hardening
• Session 0 isolation
• Least privilege
• Per service SID
• Write restricted token
• Restricted network access
• Conclusions
Introduction
• In the beginning all Windows services ran as Local
  SYSTEM account
  – Compromise of a service==full system compromise
• Later Windows services run under Local Service,
  Network Service and Local System accounts
• Since Windows Vista new services protections
  were introduced and previous weaknesses were
  corrected
  – Compromise of a service!=full system compromise
• But Windows is still not perfect and most new
  services protections can be easily bypassed...
What is impersonation and
       what are tokens?
• Impersonation is the ability of a thread to
  execute using different security information than
  the process that owns the thread
  – ACL checks are done against the impersonated users
  – Impersonation APIs: ImpersonateNamedPipeClient(),
    ImpersonateLoggedOnUser(), RpcImpersonateClient()
  – Impersonation can only be done by processes with
    “Impersonate a client after authentication”
    (SeImpersonatePrivilege)
  – When a thread impersonates it has an associated
    impersonation token
What is impersonation and
       what are tokens?
• Access token is a Windows object that
  describes the security context of a process or
  thread
  – It includes the identity and privileges of the user
    account associated with the process or thread
  – They can be Primary or Impersonation tokens
     •Primary are those that are assigned to processes
     •Impersonation are those that can be get when
     impersonation occurs
Windows 7, Vista and 2008
     services hardening
• Services hardening consists of new services
  protections implemented as a defense in depth
  mechanism
   – Session 0 isolation
   – Least privilege
   – Per service SID
   – Write restricted token
   – Restricted network access
• All protections working together “could contain”
  exploitation by limiting attacker actions when
  exploiting a vulnerability
Session 0 isolation
• System and Services processes runs on Session 0
  and user processes on Session 1, 2, etc.
• If an interactive service displays a window, user is
  asked to switch to Session 0 by “Interactive
  Services Detection” service (UI0Detect)
    – UI0Detect displays a window telling the user
      about a process trying to display a message
• User sessions can’t send windows messages to
  Session 0
• Goal: Protect against Shatter attacks
Session 0 isolation
• Protection bypass
  – None known
  – Interactive services not common
Least privilege
• Services run only with required privileges
   – For services sharing a single svchost processes
     privileges are accumulated
• Privileges can be added with
   – sc privs [service name] [Privileges]
• Privileges can be queried with
   – sc qprivs [service name]
• Goal: if a service is compromised attacker
  actions will be restricted due to few available
  privileges
Least privilege
• Protection bypass
   – Most services need and have impersonation
     privilege
     • When impersonating, service process gets privileges
       from impersonated account and could elevate privileges
  – Windows tasks can be created from a service and
    then run with full privileges
     • Services can run any program with full service account
       privileges
  – Demo
     • Creating a Windows task with full privileges from a
       service
Per service SID
• Nice feature, now service processes are well
  protected, unique SID assigned to process ACL
• Service running under “X” account can't access other
  services running under same “X” account
• Setting a Per service SID
   – sc sidtype [service name] unrestricted (or
     restricted)
• IIS worker processes and WMI process have similar
  protection
• Goal: restrict access to processes running under
  same account blocking privilege elevation
Per service SID
• Protection bypass
   – ACLs checks are performed against service SID
     and also service account
     • Shared registry keys and files break and weaken this
       protection
  – Some processes aren’t properly protected
     • SQL Server WMI process
     • Windows task processes
  – Demo
     • Elevation of privileges exploit (new Token Kidnapping
       exploit)
Write restricted token
• Nice feature, service can have write access to
  resources only if explicitly granted to the service
  SID, logon SID, Everyone SID or write-restricted SID
• Service account gets restricted from writing to
  resources
   – Good protection for registry keys and files
   – Needs proper ACLs for used resources
• Doesn’t restrict reading
• Windows Firewall service runs with write restricted
  token (sc qsidtype MpsSvc)
• Goal: if a service is compromised attacker will
  be restricted to write to resources
Write restricted token
• Protection bypass
   – Just a couple of services are write restricted by
     default (Windows Firewall service)
      • These services can and do impersonate SYSTEM account
        and administrative accounts
         – No sense in making them restricted since they can
           compromise Windows after impersonating high
           privileged accounts
         – After exploiting service just wait for an administrator
           to log in in order to elevate privileges
   – Demo
      • Windows Firewall service impersonating an administrator
Restricted network access
• Services can be restricted to only make or accept
  connections on specified ports and protocols
   – They could have no network access at all
• Implemented as Windows Service Hardening (WSH)
  rules through Windows firewall
   – WSH rules evaluated before firewall ones
   – Can't be disabled after service starts
   – Works no matter firewall is disabled
   – Processes created by a service are restricted too
• Goal: if a service is compromised attacker will
  be restricted to accept or make connections
Restricted network access
• Protection bypass
  – On Win2008 Local Service account has full control over non
    native services WSH rules registry key
     • HKEY_LOCAL_MACHINESYSTEMCurrentControlSetservicesSharedAc
       cessParametersFirewallPolicyRestrictedServicesConfigurable
     • Restrictions can be removed while service is still running
       if attacker can run code as Local Service account
  – All network restrictions can be bypassed by executing code
    under another process not directly created by the network
    restricted service such as Windows task process or SQL
    Server WMI process
• Demo
Conclusions

• New services protections can be easily bypassed
  – Just require an additional exploit step
• More Windows design changes must be done to
  make protections stronger
References
• Session 0 isolation
http://www.alex-ionescu.com/?p=59
http://blogs.technet.com/b/voy/archive/2007/02/23/servic
  es-isolation-in-session-0-of-windows-vista-and-longhorn-
  server.aspx
• Windows Services Hardening
http://blogs.technet.com/b/askperf/archive/2008/02/03/w
  s2008-windows-service-hardening.aspx
• Least Privileges
http://blogs.technet.com/b/voy/archive/2007/03/21/least-
  privilege-for-services.aspx
References
• Per Service SID
http://blogs.technet.com/b/voy/archive/2007/03/22/per-
  service-sid.aspx
• Write Restricted Token
http://blogs.technet.com/b/voy/archive/2007/04/01/write-
  restricted-token.aspx
• Network Restrictions
http://blogs.technet.com/b/voy/archive/2007/04/02/netw
  ork-restrictions-for-service-hardening.aspx
Fin

   Questions?
   Thanks


   Contact: cesar>at<argeniss>dot<com


    Argeniss – Information Security & Software
                 WE BREAK ANYTHING
                  www.argeniss.com

More Related Content

More from Michael Scovetta

Exploitation and State Machines
Exploitation and State MachinesExploitation and State Machines
Exploitation and State MachinesMichael Scovetta
 
Don't Give Credit: Hacking Arcade Machines
Don't Give Credit: Hacking Arcade MachinesDon't Give Credit: Hacking Arcade Machines
Don't Give Credit: Hacking Arcade MachinesMichael Scovetta
 
The Listening: Email Client Backdoor
The Listening: Email Client BackdoorThe Listening: Email Client Backdoor
The Listening: Email Client BackdoorMichael Scovetta
 
DEFCON 18- These Aren't the Permissions You're Looking For
DEFCON 18- These Aren't the Permissions You're Looking ForDEFCON 18- These Aren't the Permissions You're Looking For
DEFCON 18- These Aren't the Permissions You're Looking ForMichael Scovetta
 
Systematic Detection of Capability Leaks in Stock Android Smartphones
Systematic Detection of Capability Leaks in Stock Android SmartphonesSystematic Detection of Capability Leaks in Stock Android Smartphones
Systematic Detection of Capability Leaks in Stock Android SmartphonesMichael Scovetta
 
Consumer Password Worst Practices
Consumer Password Worst PracticesConsumer Password Worst Practices
Consumer Password Worst PracticesMichael Scovetta
 
A collection of examples of 64 bit errors in real programs
A collection of examples of 64 bit errors in real programsA collection of examples of 64 bit errors in real programs
A collection of examples of 64 bit errors in real programsMichael Scovetta
 
If You Don't Like the Game, Hack the Playbook... (Zatko)
If You Don't Like the Game, Hack the Playbook... (Zatko)If You Don't Like the Game, Hack the Playbook... (Zatko)
If You Don't Like the Game, Hack the Playbook... (Zatko)Michael Scovetta
 
Scaling Cyberwarfare (Roelker)
Scaling Cyberwarfare (Roelker)Scaling Cyberwarfare (Roelker)
Scaling Cyberwarfare (Roelker)Michael Scovetta
 
High Assurance Systems (Fisher)
High Assurance Systems (Fisher)High Assurance Systems (Fisher)
High Assurance Systems (Fisher)Michael Scovetta
 
PROCEED and Crowd-Sourced Formal Verification
PROCEED and Crowd-Sourced Formal VerificationPROCEED and Crowd-Sourced Formal Verification
PROCEED and Crowd-Sourced Formal VerificationMichael Scovetta
 
National Cyber Range (Ranka)
National Cyber Range (Ranka)National Cyber Range (Ranka)
National Cyber Range (Ranka)Michael Scovetta
 
Beyond Passwords (Guidorizzi)
Beyond Passwords (Guidorizzi)Beyond Passwords (Guidorizzi)
Beyond Passwords (Guidorizzi)Michael Scovetta
 
Scalable Cyber Deception (Ragsdale)
Scalable Cyber Deception (Ragsdale)Scalable Cyber Deception (Ragsdale)
Scalable Cyber Deception (Ragsdale)Michael Scovetta
 
Anomaly Detection at Multiple Scales (Waltzman)
Anomaly Detection at Multiple Scales (Waltzman)Anomaly Detection at Multiple Scales (Waltzman)
Anomaly Detection at Multiple Scales (Waltzman)Michael Scovetta
 
Secure Computer Systems (Shrobe)
Secure Computer Systems (Shrobe)Secure Computer Systems (Shrobe)
Secure Computer Systems (Shrobe)Michael Scovetta
 
DARPA: Cyber Analytical Framework (Kaufman)
DARPA: Cyber Analytical Framework (Kaufman)DARPA: Cyber Analytical Framework (Kaufman)
DARPA: Cyber Analytical Framework (Kaufman)Michael Scovetta
 

More from Michael Scovetta (20)

Exploitation and State Machines
Exploitation and State MachinesExploitation and State Machines
Exploitation and State Machines
 
Don't Give Credit: Hacking Arcade Machines
Don't Give Credit: Hacking Arcade MachinesDon't Give Credit: Hacking Arcade Machines
Don't Give Credit: Hacking Arcade Machines
 
Attacking the WebKit Heap
Attacking the WebKit HeapAttacking the WebKit Heap
Attacking the WebKit Heap
 
The Listening: Email Client Backdoor
The Listening: Email Client BackdoorThe Listening: Email Client Backdoor
The Listening: Email Client Backdoor
 
Smooth CoffeeScript
Smooth CoffeeScriptSmooth CoffeeScript
Smooth CoffeeScript
 
DEFCON 18- These Aren't the Permissions You're Looking For
DEFCON 18- These Aren't the Permissions You're Looking ForDEFCON 18- These Aren't the Permissions You're Looking For
DEFCON 18- These Aren't the Permissions You're Looking For
 
Systematic Detection of Capability Leaks in Stock Android Smartphones
Systematic Detection of Capability Leaks in Stock Android SmartphonesSystematic Detection of Capability Leaks in Stock Android Smartphones
Systematic Detection of Capability Leaks in Stock Android Smartphones
 
Consumer Password Worst Practices
Consumer Password Worst PracticesConsumer Password Worst Practices
Consumer Password Worst Practices
 
HTML5 Web Security
HTML5 Web SecurityHTML5 Web Security
HTML5 Web Security
 
A collection of examples of 64 bit errors in real programs
A collection of examples of 64 bit errors in real programsA collection of examples of 64 bit errors in real programs
A collection of examples of 64 bit errors in real programs
 
If You Don't Like the Game, Hack the Playbook... (Zatko)
If You Don't Like the Game, Hack the Playbook... (Zatko)If You Don't Like the Game, Hack the Playbook... (Zatko)
If You Don't Like the Game, Hack the Playbook... (Zatko)
 
Scaling Cyberwarfare (Roelker)
Scaling Cyberwarfare (Roelker)Scaling Cyberwarfare (Roelker)
Scaling Cyberwarfare (Roelker)
 
High Assurance Systems (Fisher)
High Assurance Systems (Fisher)High Assurance Systems (Fisher)
High Assurance Systems (Fisher)
 
PROCEED and Crowd-Sourced Formal Verification
PROCEED and Crowd-Sourced Formal VerificationPROCEED and Crowd-Sourced Formal Verification
PROCEED and Crowd-Sourced Formal Verification
 
National Cyber Range (Ranka)
National Cyber Range (Ranka)National Cyber Range (Ranka)
National Cyber Range (Ranka)
 
Beyond Passwords (Guidorizzi)
Beyond Passwords (Guidorizzi)Beyond Passwords (Guidorizzi)
Beyond Passwords (Guidorizzi)
 
Scalable Cyber Deception (Ragsdale)
Scalable Cyber Deception (Ragsdale)Scalable Cyber Deception (Ragsdale)
Scalable Cyber Deception (Ragsdale)
 
Anomaly Detection at Multiple Scales (Waltzman)
Anomaly Detection at Multiple Scales (Waltzman)Anomaly Detection at Multiple Scales (Waltzman)
Anomaly Detection at Multiple Scales (Waltzman)
 
Secure Computer Systems (Shrobe)
Secure Computer Systems (Shrobe)Secure Computer Systems (Shrobe)
Secure Computer Systems (Shrobe)
 
DARPA: Cyber Analytical Framework (Kaufman)
DARPA: Cyber Analytical Framework (Kaufman)DARPA: Cyber Analytical Framework (Kaufman)
DARPA: Cyber Analytical Framework (Kaufman)
 

Recently uploaded

Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 

Recently uploaded (20)

Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 

Windows Services Hacking

  • 1. Bypassing Windows services protections Cesar Cerrudo Argeniss
  • 2. Who am I? • Argeniss Founder and CEO (23 people company) • I have been working on security for +9 years • I have found and helped to fix hundreds of vulnerabilities in software such as MS Windows, MS SQL Server, Oracle Database Server, IBM DB2, and many more... • +50 vulnerabilities found on MS products (+20 on Windows operating systems) • I have researched and created novel attacks and exploitation techniques
  • 3. Agenda • Introduction • What is impersonation and what are tokens? • Windows 7, Vista and 2008 services hardening • Session 0 isolation • Least privilege • Per service SID • Write restricted token • Restricted network access • Conclusions
  • 4. Introduction • In the beginning all Windows services ran as Local SYSTEM account – Compromise of a service==full system compromise • Later Windows services run under Local Service, Network Service and Local System accounts • Since Windows Vista new services protections were introduced and previous weaknesses were corrected – Compromise of a service!=full system compromise • But Windows is still not perfect and most new services protections can be easily bypassed...
  • 5. What is impersonation and what are tokens? • Impersonation is the ability of a thread to execute using different security information than the process that owns the thread – ACL checks are done against the impersonated users – Impersonation APIs: ImpersonateNamedPipeClient(), ImpersonateLoggedOnUser(), RpcImpersonateClient() – Impersonation can only be done by processes with “Impersonate a client after authentication” (SeImpersonatePrivilege) – When a thread impersonates it has an associated impersonation token
  • 6. What is impersonation and what are tokens? • Access token is a Windows object that describes the security context of a process or thread – It includes the identity and privileges of the user account associated with the process or thread – They can be Primary or Impersonation tokens •Primary are those that are assigned to processes •Impersonation are those that can be get when impersonation occurs
  • 7. Windows 7, Vista and 2008 services hardening • Services hardening consists of new services protections implemented as a defense in depth mechanism – Session 0 isolation – Least privilege – Per service SID – Write restricted token – Restricted network access • All protections working together “could contain” exploitation by limiting attacker actions when exploiting a vulnerability
  • 8. Session 0 isolation • System and Services processes runs on Session 0 and user processes on Session 1, 2, etc. • If an interactive service displays a window, user is asked to switch to Session 0 by “Interactive Services Detection” service (UI0Detect) – UI0Detect displays a window telling the user about a process trying to display a message • User sessions can’t send windows messages to Session 0 • Goal: Protect against Shatter attacks
  • 9. Session 0 isolation • Protection bypass – None known – Interactive services not common
  • 10. Least privilege • Services run only with required privileges – For services sharing a single svchost processes privileges are accumulated • Privileges can be added with – sc privs [service name] [Privileges] • Privileges can be queried with – sc qprivs [service name] • Goal: if a service is compromised attacker actions will be restricted due to few available privileges
  • 11. Least privilege • Protection bypass – Most services need and have impersonation privilege • When impersonating, service process gets privileges from impersonated account and could elevate privileges – Windows tasks can be created from a service and then run with full privileges • Services can run any program with full service account privileges – Demo • Creating a Windows task with full privileges from a service
  • 12. Per service SID • Nice feature, now service processes are well protected, unique SID assigned to process ACL • Service running under “X” account can't access other services running under same “X” account • Setting a Per service SID – sc sidtype [service name] unrestricted (or restricted) • IIS worker processes and WMI process have similar protection • Goal: restrict access to processes running under same account blocking privilege elevation
  • 13. Per service SID • Protection bypass – ACLs checks are performed against service SID and also service account • Shared registry keys and files break and weaken this protection – Some processes aren’t properly protected • SQL Server WMI process • Windows task processes – Demo • Elevation of privileges exploit (new Token Kidnapping exploit)
  • 14. Write restricted token • Nice feature, service can have write access to resources only if explicitly granted to the service SID, logon SID, Everyone SID or write-restricted SID • Service account gets restricted from writing to resources – Good protection for registry keys and files – Needs proper ACLs for used resources • Doesn’t restrict reading • Windows Firewall service runs with write restricted token (sc qsidtype MpsSvc) • Goal: if a service is compromised attacker will be restricted to write to resources
  • 15. Write restricted token • Protection bypass – Just a couple of services are write restricted by default (Windows Firewall service) • These services can and do impersonate SYSTEM account and administrative accounts – No sense in making them restricted since they can compromise Windows after impersonating high privileged accounts – After exploiting service just wait for an administrator to log in in order to elevate privileges – Demo • Windows Firewall service impersonating an administrator
  • 16. Restricted network access • Services can be restricted to only make or accept connections on specified ports and protocols – They could have no network access at all • Implemented as Windows Service Hardening (WSH) rules through Windows firewall – WSH rules evaluated before firewall ones – Can't be disabled after service starts – Works no matter firewall is disabled – Processes created by a service are restricted too • Goal: if a service is compromised attacker will be restricted to accept or make connections
  • 17. Restricted network access • Protection bypass – On Win2008 Local Service account has full control over non native services WSH rules registry key • HKEY_LOCAL_MACHINESYSTEMCurrentControlSetservicesSharedAc cessParametersFirewallPolicyRestrictedServicesConfigurable • Restrictions can be removed while service is still running if attacker can run code as Local Service account – All network restrictions can be bypassed by executing code under another process not directly created by the network restricted service such as Windows task process or SQL Server WMI process • Demo
  • 18. Conclusions • New services protections can be easily bypassed – Just require an additional exploit step • More Windows design changes must be done to make protections stronger
  • 19. References • Session 0 isolation http://www.alex-ionescu.com/?p=59 http://blogs.technet.com/b/voy/archive/2007/02/23/servic es-isolation-in-session-0-of-windows-vista-and-longhorn- server.aspx • Windows Services Hardening http://blogs.technet.com/b/askperf/archive/2008/02/03/w s2008-windows-service-hardening.aspx • Least Privileges http://blogs.technet.com/b/voy/archive/2007/03/21/least- privilege-for-services.aspx
  • 20. References • Per Service SID http://blogs.technet.com/b/voy/archive/2007/03/22/per- service-sid.aspx • Write Restricted Token http://blogs.technet.com/b/voy/archive/2007/04/01/write- restricted-token.aspx • Network Restrictions http://blogs.technet.com/b/voy/archive/2007/04/02/netw ork-restrictions-for-service-hardening.aspx
  • 21. Fin  Questions?  Thanks  Contact: cesar>at<argeniss>dot<com Argeniss – Information Security & Software WE BREAK ANYTHING www.argeniss.com