What Rights Does the InstallHandler Ghost User Have?

What Rights Does the InstallHandler Ghost User Have?

On November 13, 2025, Posted by , In Apex,Salesforce Apex Tutorial, With Comments Off on What Rights Does the InstallHandler Ghost User Have?
What Rights Does the InstallHandler Ghost User Have

Question:

When a managed package with a post-install script is installed in Salesforce, the InstallHandler class runs under a special “ghost user.” What privileges does this user have? Is it associated with a documented profile?

During investigation, it appears that this user has unusual properties. For example, certain objects like CronTrigger and ApexClass cannot be accessed via SOQL, scheduled jobs created during post-install run under this context, and batch jobs also inherit the same execution user. Attempts to query the user by Id fail, and debug logs cannot be monitored. Interestingly, the UserInfo values show that this user has the type LicenseManager, with an email of noreply@salesforce.com, a package-specific username, and no session Id.

So, how restricted or privileged is this InstallHandler ghost user?

Answer:

After testing and trial-and-error investigation, it appears that the InstallHandler ghost user can effectively run with unlimited privileges under one special condition: the InstallHandler implementation class must be declared with the without sharing annotation.

Accelerate your career with CRS Info Solutions  Salesforce online training. Gain expert insights, hands-on experience, and in-depth knowledge to master the Salesforce ecosystem with confidence!!!

When the code runs in this way, the InstallHandler context can:

global class MyInstallHandler implements InstallHandler {
    global void onInstall(InstallContext context) {
        // Executes with ghost user privileges
        // If 'without sharing', has full access
        List<CronTrigger> jobs = [SELECT Id, CronJobDetailId FROM CronTrigger];
        System.debug(jobs);
    }
}

Explanation: This code defines a global InstallHandler class that runs automatically after a managed package is installed. Inside the onInstall method, it queries the CronTrigger object to retrieve scheduled job details, something normally restricted, but accessible here because the ghost user runs with elevated privileges. The System.debug statement outputs the queried job records, demonstrating how the install context can act with full system-level access if declared without sharing.

Running without sharing allows the install context to view and modify all data, as well as interrogate system-level objects such as CronTrigger and ApexClass. Moreover, this elevated context cascades into any Batch Apex or Scheduled Apex jobs launched from the post-install script. If those jobs are also defined as without sharing, they inherit the same “super user” privileges and can execute long-running operations that no regular org user could.

If the InstallHandler or subsequent jobs are defined with sharing, then these privileges are constrained and some system objects will remain inaccessible.

Summing Up

The InstallHandler ghost user in Salesforce executes post-install scripts with unique elevated privileges. When combined with the without sharing annotation, it can access and manipulate system-level objects like CronTrigger, extending these super-user rights to batch and scheduled jobs it initiates. This makes it a powerful but sensitive mechanism that developers must handle carefully to avoid unintended security risks.

Boost Your Salesforce Career with Expert Training in Ahmedabad

Take the next step in your Salesforce career with specialized online training from CRS Info Solutions in Ahmedabad. Our in-depth courses are designed for both beginners and advanced learners, covering key areas such as Salesforce Administration, Development, and AI modules. Through real-world, project-based learning, you’ll develop the skills needed to excel in the Salesforce ecosystem.

Our training offers hands-on experience, personalized mentorship, and comprehensive resources, including detailed class notes, Salesforce Training in Ahmedabad certification guidance, and interview preparation. Led by experienced industry professionals, we ensure you are fully prepared to meet the demands of the Salesforce job market and become job-ready.

Don’t wait to unlock new career opportunities—enroll now and participate in our free demo session to kickstart your Salesforce journey!!!

Comments are closed.