Platform
See

Instant Org Scan

A full X-ray of your org in about two minutes

Security Intelligence

Permissions, exposure, and risky access paths

Process Intelligence

Flows, usage, and where friction slows people down

Hubbl MCP

Headless org context for any agent

Act & Sustain

Prioritized Recommendations

Ranked fixes with ready-to-run Claude prompts

Org monitoring

Continuous scans as your org evolves

AI Readiness

Find what breaks agents before they go live

Explore the full platform
Solutions
By role

Salesforce Admins

Understand your org and act on it — no migration project

Architects & Platform Owners

Map every dependency before you change anything

RevOps & Sales Ops

Run the funnel on automation you can trust

IT & Security Leaders

Govern the access you can finally see

Consulting & SI Partners

Start every engagement already knowing the org

Enterprise & M&A Teams

Know what you're inheriting before you merge it

By outcome

AI & Agent Optimization

Stop paying to rediscover your org on every prompt

AI readiness

Build the clean foundation agents actually run on

Security & compliance

Close exposure before it becomes risk

Org cleanup & tech debt

Cut cost and complexity, ranked by impact

App rationalization

Keep the apps your team uses. Retire the rest.

See all solutions
Partners
PROGRAMS

Consulting & SI partners

Diagnose client orgs in minutes, not weeks

Salesforce account teams

Built on — and backed by - Salesforce Ventures

Technology partners

Extend Hubbl org context to your own tools

GET INVOLVED

Become a partner

Join the Hubbl partner program

Partner directory

Find a certified Hubbl partner

Partner directory
Customers
Resources
LEARN

Resource center

Playbooks for clean, AI-ready orgs

Add to Claude

Get the Hubbl MCP running in minutes

FAQs

Find quick answers to common questions

Feature Release

Our latest releases

Hubbl Learning Hub

Explore guides, FAQs, and tutorials

EXPLORE

Customer stories

Proof from orgs that turned the lights on

Trust Center

Security, privacy, and data handling

Pricing

Plans for orgs and partners

Explore resources
Pricing
Login
Get Your Org Scanned
Book a Demo

Update code susceptible to SOQL injection

Issue: Apex class contains untrusted/unescaped variables in DML queries.

‍Admin Solution

Ensure that any user-controlled variables are properly escaped and/or validated before being included in a SOQL query.

‍

Step 1: Identify Vulnerable Apex Classes

Start by identifying the Apex class or classes where untrusted or unescaped variables are being used in DML queries. You can use Hubbl Diagnostics or work with developers to review code for vulnerabilities.

To review using Hubbl Diagnostics:

  • Open your scan and select the Recommendations tab
  • Select the Details sub-tab
  • Select “Update code susceptible to SOQL injection” in the right-hand Recommendations list. (If you have a lot of recommendations, set the Metadata Categories to Custom Code to make it easier to find the particular recommendation)
  • The details list will now contain all the impacted code

‍

Step 2: Understand the Issue

SOQL injection occurs when an attacker can insert malicious SOQL code into a query, potentially accessing sensitive data that they should not have access to. For a general overview of injection attacks, see the Security Principles Trailhead module.

‍

Step 3: Communicate with Your Development Team

Share your findings with the development team. Highlight the risks associated with untrusted or unescaped variables in DML queries and the importance of fixing these vulnerabilities. Develop a plan to review and update the affected code, including prioritizing higher-risk instances such as in code that is used by anonymous or external users, and code that runs with security checks disabled.

‍

Step 4: Testing and Validation

After the developers have made the necessary changes, perform thorough testing to ensure that the vulnerability has been effectively mitigated. This includes both functional testing to verify that the application continues to behave as expected, and security testing to confirm that the SOQL injection vulnerability has been addressed.

‍

Step 5: Implement a Review Process for Future Development

Implement a process where all Apex code is reviewed for security vulnerabilities before being deployed to production. This might involve using automated tools as well as manual reviews.

‍

Step 6: Education and Training

Organize training sessions for developers on secure coding practices, emphasizing the importance of preventing SOQL injection and other common security issues.

‍

Step 7: Monitor and Audit

Use Salesforce's built-in tools and third-party security solutions, such as Hubbl Diagnostics, to continuously monitor for security vulnerabilities. Regular audits can help catch any new instances of untrusted or unescaped variables being introduced into the code.

‍

Developer Solution

Ensure that any user-controlled variables are properly escaped and/or validated before being included in an SOQL query. If building a query dynamically, generate it with fflib's Query Builder or a similar library.

‍

Step 1: Review Your Apex Code

Start by carefully reviewing your Apex code to identify any instances where variables are directly concatenated into SOQL query strings or DML statements. Look for queries that dynamically construct SOQL strings using user input or other variable data. You can use Hubbl Diagnostics or the Salesforce Code Analyzer to help identify code for review.

To review using Hubbl Org Intelligence:

  • Open your scan and select the Recommendations tab
  • Select the Details sub-tab
  • Select “Update code susceptible to SOQL injection” in the right-hand Recommendations list. (If you have a lot of recommendations, set the Metadata Categories to Custom Code to make it easier to find the particular recommendation)
  • The details list will now contain all the impacted code

To review using Salesforce Code Analyzer:

  • Have the Salesforce CLI (“sf”) installed and a project configured with a copy of your org’s code on your local machine
  • Install the Salesforce Code Analyzer plugin if it is not already installed
sf plugins install @salesforce/sfdx-scanner
  • Run the scanner command
sf scanner run --category Security --target force-app/main/default/classes

Refer to the Salesforce Code Analyzer documentation for a full list of commands and options.

‍

Step 2: Understand SOQL Injection Risks

SOQL injection occurs when an attacker can insert malicious SOQL code into a query, potentially accessing sensitive data that they should not have access to.

For a general overview of injection attacks, see the Security Principles Trailhead module. For a Salesforce and SOQL-specific approach, see the Secure Server-Side Development module.

‍

Step 3: Update code

Whenever possible, use parameterized queries to prevent SOQL injection. This means utilizing binding variables in SOQL queries, which Salesforce automatically sanitizes against SOQL injection.

String searchKeyword = 'Acme';
List<Account> accounts = [SELECT Id, Name FROM Account WHERE Name = :searchKeyword];

‍

For dynamic SOQL queries, use String.escapeSingleQuotes() to sanitize user inputs. This method escapes single quotes, a common exploit vector in SOQL injection attacks.

String userInput = 'O\'Reilly';
String sanitizedInput = String.escapeSingleQuotes(userInput);
String dynamicQuery = 'SELECT Id FROM Contact WHERE LastName = \'' + sanitizedInput + '\'';
Database.query(dynamicQuery);

‍

If you are building complex dynamic queries, consider using a third-party query builder library, such as fflib’s QueryFactory to reduce the likelihood of introducing injection vulnerabilities and improve overall readability and ease of understanding. See the Apex Enterprise Patterns: Domain & Selector Layers Trailhead module for more information.

‍

Step 4: Testing and Validation

After making the necessary changes, perform thorough testing to ensure that the vulnerability has been effectively mitigated. This includes both security testing to confirm that the SOQL injection vulnerability has been addressed, and functional testing to verify that the application continues to behave as expected.

‍

Step 5: Implement a Review Process for Future Development

Implement a process where all Apex code is reviewed for security vulnerabilities before being deployed to production. This might involve using automated tools as well as manual reviews.

‍

Step 6: Review and Refactor Legacy Code

Implementing a review process will help prevent any new issues from being introduced, but legacy code in the org may still need to be addressed. Develop a plan to review and refactor legacy Apex code to ensure it adheres to current best practices for security, especially concerning SOQL injection protection.

‍

Step 7: Stay Informed on Security Best Practices

Stay updated with Salesforce's security guidelines and best practices. Salesforce frequently updates its documentation and recommendations based on evolving security threats.

‍

Step 8: Monitor and Audit

Use Salesforce's built-in tools and third-party security solutions to continuously monitor for security vulnerabilities. Regular audits can help catch any new instances of untrusted or unescaped variables being introduced into the code. Consider implementing automated scanning as part of your code review process, either through third-party services, such as Hubbl Diagnostics, or custom scripting.

PLATFORMInstant Org ScanSecurity IntelligenceProcess IntelligenceRecommendationsOrg MonitoringHubbl MCP
SolutionsAdminsSecurity & complianceOrg cleanupCost optimization
PartnersPartner directoryConsulting & SI partnersSalesforce account teamsTechnology partners
CompanyAboutCareersContactTrust Center

The org intelligence layer for Salesforce. Turn the lights on, then fix everything.

© 2026 Hubbl Technologies, Inc. · Privacy · Terms · Cookie Settings