Running as Limited User - the Easy Way

Published Jun 26 2019 11:27 PM 622 Views
Community Manager
First published on TechNet on Mar 02, 2006
Malware has grown to epidemic proportions in the last few years. Despite applying layered security principles, including running antivirus, antispyware, and a firewall, even a careful user can fall victim to malware. Malware-infected downloads, drive-by exploits of Internet Explorer (IE) vulnerabilities, and a careless click on an Outlook attachment sent by a friend can render a system unusable and lead to several hours with the Windows setup CD and application installers.

As this eWeek study shows, one of the most effective ways to keep a system free from malware and to avoid reinstalls even if malware happens to sneak by, is to run as a limited user (a member of the Windows Users group). The vast majority of Windows users run as members of the Administrators group simply because so many operations, such as installing software and printers, changing power settings, and changing the time zone require administrator rights. Further, many applications fail when run in a limited-user account because they’re poorly written and expect to have write access to directories such as \Program Files and \Windows or registry keys under HKLM\Software.

An alternative to running as limited user is to instead run only specific Internet-facing applications as a limited user that are at greater risk of compromise, such as IE and Outlook. Microsoft promises this capability in Windows Vista with Protected-Mode IE and User Account Control (UAC), but you can achieve a form of this today on Windows 2000 and higher with the new limited user execution features of Process Explorer and PsExec.

Process Explorer’s Run as Limited User menu item in the File menu opens a dialog that looks like and acts like the standard Windows Run dialog, but that runs the target process without administrative privileges:



PsExec with the –l switch accomplishes the same thing from the command line:



An advantage to using PsExec to launch limited-user processes is that you can create PsExec desktop shortcuts for ones you commonly launch. To make a shortcut for Outlook, for example, right-click on the desktop, choose New->Shortcut, enter the path to PsExec in the location field and click Next. Enter Outlook as the name of the shortcut and press Finish. Then right click on the shortcut to open its properties, add “-l –d“ and the path to Outlook (e.g. C:\Program Files\Microsoft Office\Office11\Outlook.exe) to the text in the Target field. Finally, select Change Icon, navigate to the Outlook executable and choose the first icon. Activating the shortcut will result in a Command Prompt window briefly appearing as PsExec launches the target with limited rights.

Both Process Explorer and PsExec use the CreateRestrictedToken API to create a security context, called a token, that’s a stripped-down version of its own, removing administrative privileges and group membership. After generating a token that looks like one that Windows assigns to standard users Process Explorer calls CreateProcessAsUser to launch the target process with the new token.

You can use Process Explorer itself to compare the token of a process running with full administrative rights and one that’s limited by viewing the Security tab in the Process Properties dialog. The properties on the left are for an instance of IE running in an account with administrative group membership and the one on the right for IE launched using Run as Limited User:



The privilege lists immediately stand out as different because the limited-user token has so few privileges. Process Explorer queries the privileges assigned to the Users group and strips out all other privileges, including powerful ones like SeDebugPrivilege, SeLoadDriverPrivilege and SeRestorePrivilege.

The difference between the group lists is more subtle: both tokens contain the Builtin\Administrators group, but the group has a Deny flag in the limited-user version. Fully understanding the effect of that flag requires a quick background on the Windows security model.

Windows stores an object’s permissions in a Discretionary Access Control Lists (DACL) that consists of zero or more Access Control Entries (ACEs). Each ACE specifies the user or group to which it applies, a type of Allow or Deny and the accesses (e.g. read, delete) it allows or denies. When a process tries to open an object Windows normally considers each ACE in the object’s DACL that matches the user or any of the groups in the process’ token. However, when the Deny flag is present on a group that group is only used by during a security access check to deny access to objects, never to grant access.

CreateRestrictedToken marks groups you don’t want present in the resulting token with the Deny flag rather than removing them altogether to prevent the security hole doing so would create: a process using the new token could potentially access objects for which the removed groups have been explicitly denied access. Users would therefore be able to essentially bypass permissions by using the API. Consider a directory that has permissions denying the Builtin\Administrators account access, but allows Mark access. That directory wouldn’t be accessible by the original instance of IE above, but would be accessible by the limited user version.

The result of running applications as limited user is that malware invoked by those applications won’t be able to modify system settings, disable antivirus or antispyware, install device drivers, or configure themselves in system-wide autostart locations.

There are some limitations, however: because the limited-user processes are running in the same account and on the same desktop as other processes running with administrative privileges, sophisticated malware could potentially inject themselves into more privileged processes or remotely control them using Windows messages. When it comes to security, there’s no single cure all and every layer of protection you add could be the one that eventually saves you or your computer.

Next post I’ll take a look inside Vista’s UAC to see how it uses the same approach as Process Explorer and PsExec, but leverages changes to the Windowing system and process object security model to better isolate limited-user processes from those running with higher privilege.

Originally by Mark Russinovich on 3/2/2006 10:29:00 AM
Migrated from original Sysinternals.com/Blog
%3CLINGO-SUB%20id%3D%22lingo-sub-723506%22%20slang%3D%22en-US%22%3ERunning%20as%20Limited%20User%20-%20the%20Easy%20Way%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-723506%22%20slang%3D%22en-US%22%3E%0A%20%26lt%3Bmeta%20http-equiv%3D%22Content-Type%22%20content%3D%22text%2Fhtml%3B%20charset%3DUTF-8%22%20%2F%26gt%3B%3CSTRONG%3EFirst%20published%20on%20TechNet%20on%20Mar%2002%2C%202006%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%20Malware%20has%20grown%20to%20epidemic%20proportions%20in%20the%20last%20few%20years.%20Despite%20applying%20layered%20security%20principles%2C%20including%20running%20antivirus%2C%20antispyware%2C%20and%20a%20firewall%2C%20even%20a%20careful%20user%20can%20fall%20victim%20to%20malware.%20Malware-infected%20downloads%2C%20drive-by%20exploits%20of%20Internet%20Explorer%20(IE)%20vulnerabilities%2C%20and%20a%20careless%20click%20on%20an%20Outlook%20attachment%20sent%20by%20a%20friend%20can%20render%20a%20system%20unusable%20and%20lead%20to%20several%20hours%20with%20the%20Windows%20setup%20CD%20and%20application%20installers.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20As%20%3CA%20href%3D%22http%3A%2F%2Fwww.eweek.com%2Farticle2%2F0%2C1759%2C1891447%2C00.asp%22%20mce_href%3D%22http%3A%2F%2Fwww.eweek.com%2Farticle2%2F0%2C1759%2C1891447%2C00.asp%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3E%20this%20eWeek%20study%20%3C%2FA%3E%20shows%2C%20one%20of%20the%20most%20effective%20ways%20to%20keep%20a%20system%20free%20from%20malware%20and%20to%20avoid%20reinstalls%20even%20if%20malware%20happens%20to%20sneak%20by%2C%20is%20to%20run%20as%20a%20limited%20user%20(a%20member%20of%20the%20Windows%20Users%20group).%20The%20vast%20majority%20of%20Windows%20users%20run%20as%20members%20of%20the%20Administrators%20group%20simply%20because%20so%20many%20operations%2C%20such%20as%20installing%20software%20and%20printers%2C%20changing%20power%20settings%2C%20and%20changing%20the%20time%20zone%20require%20administrator%20rights.%20Further%2C%20many%20applications%20fail%20when%20run%20in%20a%20limited-user%20account%20because%20they%E2%80%99re%20poorly%20written%20and%20expect%20to%20have%20write%20access%20to%20directories%20such%20as%20%5CProgram%20Files%20and%20%5CWindows%20or%20registry%20keys%20under%20HKLM%5CSoftware.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20An%20alternative%20to%20running%20as%20limited%20user%20is%20to%20instead%20run%20only%20specific%20Internet-facing%20applications%20as%20a%20limited%20user%20that%20are%20at%20greater%20risk%20of%20compromise%2C%20such%20as%20IE%20and%20Outlook.%20Microsoft%20promises%20this%20capability%20in%20Windows%20Vista%20with%20%3CA%20href%3D%22http%3A%2F%2Fblogs.msdn.com%2Fie%2Farchive%2F2006%2F02%2F09%2F528963.aspx%22%20mce_href%3D%22http%3A%2F%2Fblogs.msdn.com%2Fie%2Farchive%2F2006%2F02%2F09%2F528963.aspx%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20Protected-Mode%20IE%20%3C%2FA%3E%20and%20User%20Account%20Control%20(UAC)%2C%20but%20you%20can%20achieve%20a%20form%20of%20this%20today%20on%20Windows%202000%20and%20higher%20with%20the%20new%20limited%20user%20execution%20features%20of%20Process%20Explorer%20and%20PsExec.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20Process%20Explorer%E2%80%99s%20Run%20as%20Limited%20User%20menu%20item%20in%20the%20File%20menu%20opens%20a%20dialog%20that%20looks%20like%20and%20acts%20like%20the%20standard%20Windows%20Run%20dialog%2C%20but%20that%20runs%20the%20target%20process%20without%20administrative%20privileges%3A%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CIMG%20mce_src%3D%22http%3A%2F%2Fblogs.technet.com%2Fphotos%2Fmarkrussinovich%2Fimages%2F482370%2Foriginal.aspx%22%20original-url%3D%22http%3A%2F%2Fblogs.technet.com%2Fphotos%2Fmarkrussinovich%2Fimages%2F482370%2Foriginal.aspx%22%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F120931i164A5B57B9C3D435%22%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20PsExec%20with%20the%20%E2%80%93l%20switch%20accomplishes%20the%20same%20thing%20from%20the%20command%20line%3A%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CIMG%20mce_src%3D%22http%3A%2F%2Fblogs.technet.com%2Fphotos%2Fmarkrussinovich%2Fimages%2F482371%2Foriginal.aspx%22%20original-url%3D%22http%3A%2F%2Fblogs.technet.com%2Fphotos%2Fmarkrussinovich%2Fimages%2F482371%2Foriginal.aspx%22%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F120932i1107318A68C3BA50%22%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20An%20advantage%20to%20using%20PsExec%20to%20launch%20limited-user%20processes%20is%20that%20you%20can%20create%20PsExec%20desktop%20shortcuts%20for%20ones%20you%20commonly%20launch.%20To%20make%20a%20shortcut%20for%20Outlook%2C%20for%20example%2C%20right-click%20on%20the%20desktop%2C%20choose%20New-%26gt%3BShortcut%2C%20enter%20the%20path%20to%20PsExec%20in%20the%20location%20field%20and%20click%20Next.%20Enter%20Outlook%20as%20the%20name%20of%20the%20shortcut%20and%20press%20Finish.%20Then%20right%20click%20on%20the%20shortcut%20to%20open%20its%20properties%2C%20add%20%E2%80%9C-l%20%E2%80%93d%E2%80%9C%20and%20the%20path%20to%20Outlook%20(e.g.%20C%3A%5CProgram%20Files%5CMicrosoft%20Office%5COffice11%5COutlook.exe)%20to%20the%20text%20in%20the%20Target%20field.%20Finally%2C%20select%20Change%20Icon%2C%20navigate%20to%20the%20Outlook%20executable%20and%20choose%20the%20first%20icon.%20Activating%20the%20shortcut%20will%20result%20in%20a%20Command%20Prompt%20window%20briefly%20appearing%20as%20PsExec%20launches%20the%20target%20with%20limited%20rights.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20Both%20Process%20Explorer%20and%20PsExec%20use%20the%20%3CA%20href%3D%22http%3A%2F%2Fwindowssdk.msdn.microsoft.com%2Flibrary%2Fdefault.asp%3Furl%3D%2Flibrary%2Fen-us%2Fsecauthz%2Fsecurity%2Fcreaterestrictedtoken.asp%22%20mce_href%3D%22http%3A%2F%2Fwindowssdk.msdn.microsoft.com%2Flibrary%2Fdefault.asp%3Furl%3D%2Flibrary%2Fen-us%2Fsecauthz%2Fsecurity%2Fcreaterestrictedtoken.asp%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20CreateRestrictedToken%20%3C%2FA%3E%20API%20to%20create%20a%20security%20context%2C%20called%20a%20token%2C%20that%E2%80%99s%20a%20stripped-down%20version%20of%20its%20own%2C%20removing%20administrative%20privileges%20and%20group%20membership.%20After%20generating%20a%20token%20that%20looks%20like%20one%20that%20Windows%20assigns%20to%20standard%20users%20Process%20Explorer%20calls%20CreateProcessAsUser%20to%20launch%20the%20target%20process%20with%20the%20new%20token.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20You%20can%20use%20Process%20Explorer%20itself%20to%20compare%20the%20token%20of%20a%20process%20running%20with%20full%20administrative%20rights%20and%20one%20that%E2%80%99s%20limited%20by%20viewing%20the%20Security%20tab%20in%20the%20Process%20Properties%20dialog.%20The%20properties%20on%20the%20left%20are%20for%20an%20instance%20of%20IE%20running%20in%20an%20account%20with%20administrative%20group%20membership%20and%20the%20one%20on%20the%20right%20for%20IE%20launched%20using%20Run%20as%20Limited%20User%3A%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CIMG%20mce_src%3D%22http%3A%2F%2Fblogs.technet.com%2Fphotos%2Fmarkrussinovich%2Fimages%2F482372%2Foriginal.aspx%22%20original-url%3D%22http%3A%2F%2Fblogs.technet.com%2Fphotos%2Fmarkrussinovich%2Fimages%2F482372%2Foriginal.aspx%22%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F120933i9E01D5322DDB0993%22%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20The%20privilege%20lists%20immediately%20stand%20out%20as%20different%20because%20the%20limited-user%20token%20has%20so%20few%20privileges.%20Process%20Explorer%20queries%20the%20privileges%20assigned%20to%20the%20Users%20group%20and%20strips%20out%20all%20other%20privileges%2C%20including%20powerful%20ones%20like%20SeDebugPrivilege%2C%20SeLoadDriverPrivilege%20and%20SeRestorePrivilege.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20The%20difference%20between%20the%20group%20lists%20is%20more%20subtle%3A%20both%20tokens%20contain%20the%20Builtin%5CAdministrators%20group%2C%20but%20the%20group%20has%20a%20Deny%20flag%20in%20the%20limited-user%20version.%20Fully%20understanding%20the%20effect%20of%20that%20flag%20requires%20a%20quick%20background%20on%20the%20Windows%20security%20model.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20Windows%20stores%20an%20object%E2%80%99s%20permissions%20in%20a%20Discretionary%20Access%20Control%20Lists%20(DACL)%20that%20consists%20of%20zero%20or%20more%20Access%20Control%20Entries%20(ACEs).%20Each%20ACE%20specifies%20the%20user%20or%20group%20to%20which%20it%20applies%2C%20a%20type%20of%20Allow%20or%20Deny%20and%20the%20accesses%20(e.g.%20read%2C%20delete)%20it%20allows%20or%20denies.%20When%20a%20process%20tries%20to%20open%20an%20object%20Windows%20normally%20considers%20each%20ACE%20in%20the%20object%E2%80%99s%20DACL%20that%20matches%20the%20user%20or%20any%20of%20the%20groups%20in%20the%20process%E2%80%99%20token.%20However%2C%20when%20the%20Deny%20flag%20is%20present%20on%20a%20group%20that%20group%20is%20only%20used%20by%20during%20a%20security%20access%20check%20to%20deny%20access%20to%20objects%2C%20never%20to%20grant%20access.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20CreateRestrictedToken%20marks%20groups%20you%20don%E2%80%99t%20want%20present%20in%20the%20resulting%20token%20with%20the%20Deny%20flag%20rather%20than%20removing%20them%20altogether%20to%20prevent%20the%20security%20hole%20doing%20so%20would%20create%3A%20a%20process%20using%20the%20new%20token%20could%20potentially%20access%20objects%20for%20which%20the%20removed%20groups%20have%20been%20explicitly%20denied%20access.%20Users%20would%20therefore%20be%20able%20to%20essentially%20bypass%20permissions%20by%20using%20the%20API.%20Consider%20a%20directory%20that%20has%20permissions%20denying%20the%20Builtin%5CAdministrators%20account%20access%2C%20but%20allows%20Mark%20access.%20That%20directory%20wouldn%E2%80%99t%20be%20accessible%20by%20the%20original%20instance%20of%20IE%20above%2C%20but%20would%20be%20accessible%20by%20the%20limited%20user%20version.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20The%20result%20of%20running%20applications%20as%20limited%20user%20is%20that%20malware%20invoked%20by%20those%20applications%20won%E2%80%99t%20be%20able%20to%20modify%20system%20settings%2C%20disable%20antivirus%20or%20antispyware%2C%20install%20device%20drivers%2C%20or%20configure%20themselves%20in%20system-wide%20autostart%20locations.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20There%20are%20some%20limitations%2C%20however%3A%20because%20the%20limited-user%20processes%20are%20running%20in%20the%20same%20account%20and%20on%20the%20same%20desktop%20as%20other%20processes%20running%20with%20administrative%20privileges%2C%20sophisticated%20malware%20could%20potentially%20inject%20themselves%20into%20more%20privileged%20processes%20or%20remotely%20control%20them%20using%20Windows%20messages.%20When%20it%20comes%20to%20security%2C%20there%E2%80%99s%20no%20single%20cure%20all%20and%20every%20layer%20of%20protection%20you%20add%20could%20be%20the%20one%20that%20eventually%20saves%20you%20or%20your%20computer.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20Next%20post%20I%E2%80%99ll%20take%20a%20look%20inside%20Vista%E2%80%99s%20UAC%20to%20see%20how%20it%20uses%20the%20same%20approach%20as%20Process%20Explorer%20and%20PsExec%2C%20but%20leverages%20changes%20to%20the%20Windowing%20system%20and%20process%20object%20security%20model%20to%20better%20isolate%20limited-user%20processes%20from%20those%20running%20with%20higher%20privilege.%20%3CBR%20%2F%3E%3CDIV%20style%3D%22CLEAR%3A%20both%3B%20PADDING-BOTTOM%3A%200.25em%22%3E%0A%20%20%3C%2FDIV%3E%3CBR%20%2F%3E%20%3CI%3EOriginally%20by%20Mark%20Russinovich%20on%203%2F2%2F2006%2010%3A29%3A00%20AM%20%3C%2FI%3E%20%3CBR%20%2F%3E%20%3CI%3E%20Migrated%20from%20original%20Sysinternals.com%2FBlog%3C%2FI%3E%20%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-723506%22%20slang%3D%22en-US%22%3EFirst%20published%20on%20TechNet%20on%20Mar%2002%2C%202006%20Malware%20has%20grown%20to%20epidemic%20proportions%20in%20the%20last%20few%20years.%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-723506%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMark%20Russinovich%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Version history
Last update:
‎Jun 26 2019 11:27 PM
Updated by: