SlideShare a Scribd company logo
December 1, 2015
Lorem Ipsum Dolor
Speakers
Swapnil Shinde
Product Security Engineer
@Swapnil34
Nitin Arya
Product Security Analyst
@n_arya0
Forward-Looking Statement
Statement under the Private Securities Litigation Reform Act of 1995: This presentation may contain forward-looking statements that involve
risks, uncertainties, and assumptions. If any such uncertainties materialize or if any of the assumptions proves incorrect, the results of
salesforce.com, inc. could differ materially from the results expressed or implied by the forward-looking statements we make. All statements other
than statements of historical fact could be deemed forward-looking, including any projections of product or service availability, subscriber growth,
earnings, revenues, or other financial items and any statements regarding strategies or plans of management for future operations, statements of
belief, any statements concerning new, planned, or upgraded services or technology developments and customer contracts or use of our services.
The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new functionality for
our service, new products and services, our new business model, our past operating losses, possible fluctuations in our operating results and rate
of growth, interruptions or delays in our Web hosting, breach of our security measures, the outcome of any litigation, risks associated with
completed and any possible mergers and acquisitions, the immature market in which we operate, our relatively limited operating history, our ability
to expand, retain, and motivate our employees and manage our growth, new releases of our service and successful customer deployment, our
limited history reselling non-salesforce.com products, and utilization and selling to larger enterprise customers. Further information on potential
factors that could affect the financial results of salesforce.com, inc. is included in our annual report on Form 10-K for the most recent fiscal year
and in our quarterly report on Form 10-Q for the most recent fiscal quarter. These documents and others containing important disclosures are
available on the SEC Filings section of the Investor Information section of our Web site.
Any unreleased services or features referenced in this or other presentations, press releases or public statements are not currently available and
may not be delivered on time or at all. Customers who purchase our services should make the purchase decisions based upon features that are
currently available. Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements.
Agenda
• Overview
- Integrating your external applications securely with Salesforce
• Leveraging JavaScript Remoting with Visualforce
- Extend Salesforce functionality with external app intergrations
- Map user identities to the external systems
- Grant access to Salesforce data without breaking security model
• Using Remote Objects with Angular.js
- Secrets in named credentials
- Secrets in custom settings
- Proper usage of secrets
Building Salesforce Integrations
• Extend Salesforce funcationality with external app integrations.
• Building data flows and interactions between your external app
and Salesforce.
• Need a way to map Salesforce user identity to your external
system.
• Need a way to authenticate and secure data flows between the
two systems.
• Need a way to grant access to Salesforce data without breaking
the Salesforce security model or trust in the Salesforce platform.
Integration Methods – Apex Callouts
• Use Apex code to access external REST API’s
• Can be used to send data out or pull data to/from an
external service
• Actions must be initiated by a user action from within
Salesforce
• Partners fail security review here*
Salesforce
Internet
Web service
Integration Methods – API/OAuth
• Salesforce has several API’s for developers
• To use these API’s authentica via
- SOAP API username/password login
- OAUTH authentication flow
• Delegated authentication
- Forward username and password ( sent over internet* )
• Federated Authentication using SAML (Single sign on*)
Salesforce Web service
REST
SOA
P
Integration Methods – API - OAuth
• Salesforce has several API’s for developers
• External services can authenticate with Salesforce via OAuth and
receive access tokens
• Tokens must be treated with same sensitivity as a password
• Utilize public-facing API’s to share data with Salesforce instances
• Developers can expose custom Apex REST endpoints
• Outbound messaging
SOAP
RES
T
Integration Methods
Connected App
• Runs on the Salesforce app canvas.
• Does not have access to the Salesforce app DOM at any time.
• Authenticate via OAuth or SAML using Salesforce credentials.
• Easy way to integrate an external application into the Salesforce
“skin”.
• The OAuth scope for the connected app determines the
amount of access this app would have to your Salesforce data.
• Make sure to provide least privilege to the OAuth token being
created.
Integration User or End User
Integration User
• Creating an integration user to make callouts from the external
app into Salesforce.
• Lets you create a least privilege integration user to perform
certain operations required by the app.
• You don’t have to provide API access to all users.
• Only on credential to manage on the external system.
• You have to make sure that the Salesforce security model is not
broken when the external system accesses Salesforce data.
Integration User or End User
End User
• Lets your external app make requests as current logged in user
with the specified OAuth scope.
• Lets the user select if they want to allow or access or not.
• Preserves the Salesforce security model in your external
requests without any additional measures.
• The external app needs to make sure all end user OAuth
credentials are stored secureon the external system.
Setting Up A Connected App
Go to Setup > Create > Apps > New Connected App
Setting Up A Connected App
Advantages of Connected Apps
• No need for custom authentication logic.
• Least privilege access control based on the external app
use case.
• Easy to revoke access for misbehaving apps.
• Out of box functionality for standard Auth protocols.
• Can provide access without sharing Salesforce username
password with the external app.
Credential Handling
• External app credentials (consumer key/secret) should be
stored securely off the Salesforce platform.
• Salesforce OAuth tokens should be stored securely off the
platform using the industry best practice for your
development platform.
• API tokens for the external app should be stored via
Protected custom settings inside Salesforce.
• All credentials should be secure in transit by using HTTPS
(TLS) for all communications.
Transport Security
Security Expectations of HTTP
• None.
• Anyone on the network can eavesdrop traffic.
• Anyone on the network can modify content.
• Anyone on the network can divert traffic.
Transport Security – What is TLS?
• A user visiting a site over HTTP has no assurance that the
user is interacting with the legitimate site.
• The Transport Layer Security protocol allows for
secure communication between applications and
users.
• Uses PKI (Public Key Infrastructure) to have a Trusted
Certificate Authority (CA) vouch for the server’s identity.
• Prevents tampering, eavesdropping, and man-in-the-
middle attacks against secure communications. Provides
authentication and confidentiality.
Mutual TLS
• Salesforce supports Mutual TLS for communications
between Salesforce and your external server.
• This allows you to do a two-way verification, where the
client and server can confirm one another’s identity.
• Good for server to server authentication, where the client
is not prompting a user to log in manually.
Mutual TLS
Salesforce Mutual TLS
• Client certificates are uploaded and stored in the
Salesforce database, where they are used for
verification.
• You can also download the Salesforce client certificate to
authenticate on your web server, when making Apex
callouts, etc.
• Salesforce provides a mechanism to prevent falling back
to the standard TLS port.
Setting Up Mutual TLS
• Have mutual TLS enabled for your organization.
• Generate Certificate Signing Request (CSR) and
acquire a certificate form a Trusted CA.
Salesforce Mutual TLS
• Upload the certificate to Security Controls | Certificate
and Key Management.
• Enable “Enforce SSL/TLS Mutual Authentication”
permission for the API client user. This will force mutual
TLS on port 8443 for this user.
• This user permission can be added via a PermSet or by
adding the permission to the user profile.
• Configure the API client to connect on port 8443 and
present the client certificate.
Setting Up Mutual TLS
Why Use Mutual TLS?
• This seems like a lot of work! Why should I do this?
• Provides you a good way to authenticate both parties
(Salesforce and external app) when building external
integrations.
• You don’t just have to rely on IP range restrictions and
static API keys for client authentication.
• Out of the box mutual TLS implementation provides
authentication and confidentiality.
Part 2:
Secret Protection
Primary Topic Today: Secrets
• We will be covering developer-oriented topics on secret
storage for the Salesforce Platform.
• Specific features to cover include:
– Secrets in named credentials
– Secrets in custom settings
– Proper secret usage
– Protected Custom Metadata Types ???????????
• Useful for anyone in the following areas:
– Salesforce Developers (primarily)
– Salesforce Administrators
– Prospective Partners
What is a secret?
• Simple Definition: A piece of data that requires higher than
normal protection.
• For Our Purposes: A secret will be a piece of data that
nobody should see, like a password or encryption key.
Who do we secure secrets from?
• Attackers
• Regular Users
• Partners
• Administrators (Biggest Challenge)
• Basically, everyone… Why?
• Theft of data
• Impersonation
• Privilege Escalation
Secret in Named Credentials
Named Credentials Overview
Named crewdentials are a feature for secret storage built into
the Salesforce platform.
• Available in the “Security” setup menu
• Point & click creation
• No Code required to store secret
Named Credentials - Usage
• Create a new named credential
• Add the URL + secret to the named credential
• Invoke the named credential in the httpRequest
HttpRequest req = new HttpRequest();
req.setEndpoint('callout:NamedCredential');
req.setMethod('GET');
Http http = new Http();
HTTPResponse res = http.send(req);
return res.getBody();
Pros
• Easy to create.
• Easy to invoke.
• Secret is not visible in the UI
and code to anyone.
• Secret is not leaked in the
debug logs.
Cons
• Only works for httpRequests
and certain authentication
schemes like OAuth 2.0.
• URL can be updated in the
setup, potentially leaking
secret. ???
Named Credentials - Breakdown
Demo:
Secrets in Named Credentials
Custom Settings Overview
Custom settings are stripped down sObjects exposed to the
application cache, enabling efficient access for developers.
Protected versus Public: What is the difference?
Protected Custom Settings can only be accessed from the namespace
they exist in.
• In a managed package, the namespace is that of the package.
• In an unmanaged package, the namespace is the local namespace (so
no effect).
What does this mean?
• Managed protected Custom Settings – Extra Security Benefits
• Managed Public/ Local Public/ Local Protected – No security benefits,
worse for secrets than sObjects.
Managed Protected Custom Settings –
Storage Method
1. Create a managed package.
2. Create a protected custom setting inside the package.
3. Create a Visualforce page inside the package to
create/update the secret.
- Transient string (in controller), should not return secret to the view state.
4. Access and use the secret inside the managed package.
Custom Setting Diagram
Pros
• Secret only available to Apex
code within managed
package namespace.
• Can store encryption key to
scale.
Cons
• Requires a managed
package!
• Methods must be well-coded
to prevent secret exposure.
Managed Protected Custom Setting - Breakdown
Managed Package Architecture
Demo: Secrets in Custom Settings
Using Managed Protected Custom
Settings Properly
Overview
Using Managed Protected Custom Settings Properly
Secret storage solutions with managed protected custom settings
are developed in Apex and Visualforce, and because of this there
are some best practices that must be followed:
• Properly encapsulating secret usage in the managed package
• Properly handling secret dependencies
• Avoiding secret reflection
Properly Encapsulating Secret Usage
What is encapsulation? Keeping functionality inside the managed
package.
Why encapsulate? Namespace benefits on work INSIDE the
managed package. Anything leaving the package loses benefits.
Things to consider for encapsulation:
• User interaction - Visualforce page/component inside the managed
package.
• Using the secret – Code must be contained within the managed
package.
• Invoking secret usage - Done with a global method, secret never
returned outside of the managed package.
Managed Package Architecture
Properly Handling Secret Dependencies
What are secret dependencies? If a secret is tied to another
piece of information, a dependency is created.
Examples:
• Passwords can be dependent on URLs.
• Encryption keys can be dependent on Salts.
Secret dependency best practices:
• Secrets and dependencies are controlled from the same place
• If dependent is updated, secret should be updated. This prevents the
attacker from gaining additional information.
• Example: If a URL is updated, password should change too!
Avoiding Secret Reflection
What is secret reflection?
Developers often mistakenly allow a secret to be reflected from the
controller (Apex) to the view (Visualforce). Since the view is client
side, the risk of secret exposure increases dramatically!
Secret reflection Best Practices
• Beware hidden inputs – hidden inputs often show secret in clear within
source.
• Use transient keyword – transient keyword prevents secret from being
stored in the Visualforce viewstate.
Demo: Proper Secret Usage
Recap
1. Named Credentials
• Pro – Simple. No secret refelcted in UI or debug logs.
• Con – URL can be changed and secret leaked, only works with httpRequests.
- Works well with: Passwords and OAuth tokens that don’t come with admin
privileges.
2. Managed Protected Custom Setting (Secret Storage Best Practice)
• Pro – Most secure option. Protects against users with elevated permissions such
as Modify all Data.
• Con – Requires a managed package. Requires careful attention to code (see
below).
- Works well with: Passwords, OAuth tokens, Encryption keys.
3. Using Managed Protected Custom Settings Properly
• Properly encapsulating secret usage in the managed package.
• Properly handling secret dependencies (update password when updating URL).
• Avoiding secret reflection (beware hidden inputs use transient keyword).
Additional Resources
• Secure Coding Guidelines - https:/
developer.salesforce.com/page/Secure_Coding_Storing_Secrets
• Intro to Managed Packages -
https://developer.salesforce.com/page/An_Introduction_to_Packaging
• Salesforce StackExchange –
http://salesforce.stackexchange.com/questions/tagged/security
• Developer.Salesforce.com Security Forum -
https://developer.salesforce.com/forums (full link hidden)
• Security Office Hours (Partners) -
http://security.force.com/security/contact/ohours
• Security Implementation Guide -
https://developer.salesforce.com/././securityImplGuide/ (full link hidden)
• Force.com Security Essentials Course -
https://trustacademy.salesforce.com
#forcewebinar
Additional Resources
• Digging deep into Oauth 2.0
• Salesforce trust academy
• Salesforce generate CSR
• Salesforce mutual TLS setup
• Salesforce connected apps
Q & A
Try Trailhead: trailhead.salesforce.com
Join the conversation: @salesforcedevs
Thank You

More Related Content

What's hot

Coding in the App Cloud
Coding in the App CloudCoding in the App Cloud
Coding in the App Cloud
Salesforce Developers
 
Best Practices for Lightning Apps
Best Practices for Lightning AppsBest Practices for Lightning Apps
Best Practices for Lightning Apps
Mark Adcock
 
Diving Into Heroku Private Spaces
Diving Into Heroku Private SpacesDiving Into Heroku Private Spaces
Diving Into Heroku Private Spaces
Salesforce Developers
 
Lightning web components episode 2- work with salesforce data
Lightning web components   episode 2- work with salesforce dataLightning web components   episode 2- work with salesforce data
Lightning web components episode 2- work with salesforce data
Salesforce Developers
 
Unleash the Power of Apex Realtime Debugger
Unleash the Power of Apex Realtime DebuggerUnleash the Power of Apex Realtime Debugger
Unleash the Power of Apex Realtime Debugger
Salesforce Developers
 
Building a Single Page App with Lightning Components
Building a Single Page App with Lightning ComponentsBuilding a Single Page App with Lightning Components
Building a Single Page App with Lightning Components
Salesforce Developers
 
Building BOTS on App Cloud
Building BOTS on App CloudBuilding BOTS on App Cloud
Building BOTS on App Cloud
Salesforce Developers
 
Build, Manage, and Deploy Mobile Apps Faster with App Cloud Mobile
Build, Manage, and Deploy Mobile Apps Faster with App Cloud MobileBuild, Manage, and Deploy Mobile Apps Faster with App Cloud Mobile
Build, Manage, and Deploy Mobile Apps Faster with App Cloud Mobile
Salesforce Developers
 
Build Better Communities with Lightning
Build Better Communities with LightningBuild Better Communities with Lightning
Build Better Communities with Lightning
Salesforce Developers
 
Lightning components performance best practices
Lightning components performance best practicesLightning components performance best practices
Lightning components performance best practices
Salesforce Developers
 
Coding Apps in the Cloud with Force.com - Part 2
Coding Apps in the Cloud with Force.com - Part 2Coding Apps in the Cloud with Force.com - Part 2
Coding Apps in the Cloud with Force.com - Part 2
Salesforce Developers
 
TrailheaDX India : Developer Highlights
TrailheaDX India : Developer HighlightsTrailheaDX India : Developer Highlights
TrailheaDX India : Developer Highlights
Salesforce Developers
 
Secure Development on the Salesforce Platform - Part 2
Secure Development on the Salesforce Platform - Part 2Secure Development on the Salesforce Platform - Part 2
Secure Development on the Salesforce Platform - Part 2
Salesforce Developers
 
Introduction to the Wave Platform API
Introduction to the Wave Platform APIIntroduction to the Wave Platform API
Introduction to the Wave Platform API
Salesforce Developers
 
Introduction to Apex for Developers
Introduction to Apex for DevelopersIntroduction to Apex for Developers
Introduction to Apex for Developers
Salesforce Developers
 
Lightning Out: Components for the Rest of the World
Lightning Out: Components for the Rest of the WorldLightning Out: Components for the Rest of the World
Lightning Out: Components for the Rest of the World
Salesforce Developers
 
Secure Development on the Salesforce Platform - Part I
Secure Development on the Salesforce Platform - Part ISecure Development on the Salesforce Platform - Part I
Secure Development on the Salesforce Platform - Part I
Salesforce Developers
 
Advanced Lightning Components
Advanced Lightning ComponentsAdvanced Lightning Components
Advanced Lightning Components
Salesforce Developers
 
Javascript Security and Lightning Locker Service
Javascript Security and Lightning Locker ServiceJavascript Security and Lightning Locker Service
Javascript Security and Lightning Locker Service
Salesforce Developers
 
Mds cloud saturday 2015 salesforce intro
Mds cloud saturday 2015 salesforce introMds cloud saturday 2015 salesforce intro
Mds cloud saturday 2015 salesforce intro
David Scruggs
 

What's hot (20)

Coding in the App Cloud
Coding in the App CloudCoding in the App Cloud
Coding in the App Cloud
 
Best Practices for Lightning Apps
Best Practices for Lightning AppsBest Practices for Lightning Apps
Best Practices for Lightning Apps
 
Diving Into Heroku Private Spaces
Diving Into Heroku Private SpacesDiving Into Heroku Private Spaces
Diving Into Heroku Private Spaces
 
Lightning web components episode 2- work with salesforce data
Lightning web components   episode 2- work with salesforce dataLightning web components   episode 2- work with salesforce data
Lightning web components episode 2- work with salesforce data
 
Unleash the Power of Apex Realtime Debugger
Unleash the Power of Apex Realtime DebuggerUnleash the Power of Apex Realtime Debugger
Unleash the Power of Apex Realtime Debugger
 
Building a Single Page App with Lightning Components
Building a Single Page App with Lightning ComponentsBuilding a Single Page App with Lightning Components
Building a Single Page App with Lightning Components
 
Building BOTS on App Cloud
Building BOTS on App CloudBuilding BOTS on App Cloud
Building BOTS on App Cloud
 
Build, Manage, and Deploy Mobile Apps Faster with App Cloud Mobile
Build, Manage, and Deploy Mobile Apps Faster with App Cloud MobileBuild, Manage, and Deploy Mobile Apps Faster with App Cloud Mobile
Build, Manage, and Deploy Mobile Apps Faster with App Cloud Mobile
 
Build Better Communities with Lightning
Build Better Communities with LightningBuild Better Communities with Lightning
Build Better Communities with Lightning
 
Lightning components performance best practices
Lightning components performance best practicesLightning components performance best practices
Lightning components performance best practices
 
Coding Apps in the Cloud with Force.com - Part 2
Coding Apps in the Cloud with Force.com - Part 2Coding Apps in the Cloud with Force.com - Part 2
Coding Apps in the Cloud with Force.com - Part 2
 
TrailheaDX India : Developer Highlights
TrailheaDX India : Developer HighlightsTrailheaDX India : Developer Highlights
TrailheaDX India : Developer Highlights
 
Secure Development on the Salesforce Platform - Part 2
Secure Development on the Salesforce Platform - Part 2Secure Development on the Salesforce Platform - Part 2
Secure Development on the Salesforce Platform - Part 2
 
Introduction to the Wave Platform API
Introduction to the Wave Platform APIIntroduction to the Wave Platform API
Introduction to the Wave Platform API
 
Introduction to Apex for Developers
Introduction to Apex for DevelopersIntroduction to Apex for Developers
Introduction to Apex for Developers
 
Lightning Out: Components for the Rest of the World
Lightning Out: Components for the Rest of the WorldLightning Out: Components for the Rest of the World
Lightning Out: Components for the Rest of the World
 
Secure Development on the Salesforce Platform - Part I
Secure Development on the Salesforce Platform - Part ISecure Development on the Salesforce Platform - Part I
Secure Development on the Salesforce Platform - Part I
 
Advanced Lightning Components
Advanced Lightning ComponentsAdvanced Lightning Components
Advanced Lightning Components
 
Javascript Security and Lightning Locker Service
Javascript Security and Lightning Locker ServiceJavascript Security and Lightning Locker Service
Javascript Security and Lightning Locker Service
 
Mds cloud saturday 2015 salesforce intro
Mds cloud saturday 2015 salesforce introMds cloud saturday 2015 salesforce intro
Mds cloud saturday 2015 salesforce intro
 

Similar to Secure Development on the Salesforce Platform - Part 3

Secure Coding: SSL, SOAP, and REST
Secure Coding: SSL, SOAP, and RESTSecure Coding: SSL, SOAP, and REST
Secure Coding: SSL, SOAP, and REST
Salesforce Developers
 
Secure Salesforce: Hardened Apps with the Mobile SDK
Secure Salesforce: Hardened Apps with the Mobile SDKSecure Salesforce: Hardened Apps with the Mobile SDK
Secure Salesforce: Hardened Apps with the Mobile SDK
Salesforce Developers
 
Secure Salesforce: Hardened Apps with the Mobile SDK
Secure Salesforce: Hardened Apps with the Mobile SDKSecure Salesforce: Hardened Apps with the Mobile SDK
Secure Salesforce: Hardened Apps with the Mobile SDK
Martin Vigo
 
Secure Salesforce: Lightning Components Best Practices
Secure Salesforce: Lightning Components Best PracticesSecure Salesforce: Lightning Components Best Practices
Secure Salesforce: Lightning Components Best Practices
Salesforce Developers
 
Salesforce Identity Management
Salesforce Identity ManagementSalesforce Identity Management
Salesforce Identity Management
Jayant Jindal
 
Enterprise and Social Integration Using Force.com
Enterprise and Social Integration Using Force.comEnterprise and Social Integration Using Force.com
Enterprise and Social Integration Using Force.com
Salesforce Developers
 
Blurring the Boundaries Between Salesforce Orgs
Blurring the Boundaries Between Salesforce OrgsBlurring the Boundaries Between Salesforce Orgs
Blurring the Boundaries Between Salesforce Orgs
Salesforce Developers
 
Introduction to the Salesforce Security Model
Introduction to the Salesforce Security ModelIntroduction to the Salesforce Security Model
Introduction to the Salesforce Security Model
Salesforce Developers
 
Control your world using the Salesforce1 Platform (IoT)
Control your world using the Salesforce1 Platform (IoT)Control your world using the Salesforce1 Platform (IoT)
Control your world using the Salesforce1 Platform (IoT)
InternetCreations
 
What’s new in summer’15 release - Security & Compliance
What’s new in summer’15 release - Security & ComplianceWhat’s new in summer’15 release - Security & Compliance
What’s new in summer’15 release - Security & Compliance
Shesh Kondi
 
What’s new in summer’15 release - Security & Compliance
What’s new in summer’15 release - Security & ComplianceWhat’s new in summer’15 release - Security & Compliance
What’s new in summer’15 release - Security & Compliance
Shesh Kondi
 
Introduction to WebRTC on the Force.com Platform
Introduction to WebRTC on the Force.com PlatformIntroduction to WebRTC on the Force.com Platform
Introduction to WebRTC on the Force.com Platform
Salesforce Developers
 
Secure Salesforce: Org Access Controls
Secure Salesforce: Org Access ControlsSecure Salesforce: Org Access Controls
Secure Salesforce: Org Access Controls
Salesforce Developers
 
Introduction to lightning out df16
Introduction to lightning out   df16Introduction to lightning out   df16
Introduction to lightning out df16
Mohith Shrivastava
 
MuleSoft Surat Virtual Meetup#24 - MuleSoft and Salesforce Integration and De...
MuleSoft Surat Virtual Meetup#24 - MuleSoft and Salesforce Integration and De...MuleSoft Surat Virtual Meetup#24 - MuleSoft and Salesforce Integration and De...
MuleSoft Surat Virtual Meetup#24 - MuleSoft and Salesforce Integration and De...
Jitendra Bafna
 
Salesforce shield & summer 20 release
Salesforce shield & summer 20 releaseSalesforce shield & summer 20 release
Salesforce shield & summer 20 release
Devendra Sawant
 
Securing ap is oauth and fine grained access control
Securing ap is   oauth and fine grained access controlSecuring ap is   oauth and fine grained access control
Securing ap is oauth and fine grained access control
AaronLieberman5
 
Build Consumer-Facing Apps with Heroku Connect
Build Consumer-Facing Apps with Heroku ConnectBuild Consumer-Facing Apps with Heroku Connect
Build Consumer-Facing Apps with Heroku Connect
Jeff Douglas
 
Designing custom REST and SOAP interfaces on Force.com
Designing custom REST and SOAP interfaces on Force.comDesigning custom REST and SOAP interfaces on Force.com
Designing custom REST and SOAP interfaces on Force.com
Steven Herod
 
Cache Security- Adding Security to Non-Secure Applications
Cache Security- Adding Security to Non-Secure ApplicationsCache Security- Adding Security to Non-Secure Applications
Cache Security- Adding Security to Non-Secure Applications
InterSystems Corporation
 

Similar to Secure Development on the Salesforce Platform - Part 3 (20)

Secure Coding: SSL, SOAP, and REST
Secure Coding: SSL, SOAP, and RESTSecure Coding: SSL, SOAP, and REST
Secure Coding: SSL, SOAP, and REST
 
Secure Salesforce: Hardened Apps with the Mobile SDK
Secure Salesforce: Hardened Apps with the Mobile SDKSecure Salesforce: Hardened Apps with the Mobile SDK
Secure Salesforce: Hardened Apps with the Mobile SDK
 
Secure Salesforce: Hardened Apps with the Mobile SDK
Secure Salesforce: Hardened Apps with the Mobile SDKSecure Salesforce: Hardened Apps with the Mobile SDK
Secure Salesforce: Hardened Apps with the Mobile SDK
 
Secure Salesforce: Lightning Components Best Practices
Secure Salesforce: Lightning Components Best PracticesSecure Salesforce: Lightning Components Best Practices
Secure Salesforce: Lightning Components Best Practices
 
Salesforce Identity Management
Salesforce Identity ManagementSalesforce Identity Management
Salesforce Identity Management
 
Enterprise and Social Integration Using Force.com
Enterprise and Social Integration Using Force.comEnterprise and Social Integration Using Force.com
Enterprise and Social Integration Using Force.com
 
Blurring the Boundaries Between Salesforce Orgs
Blurring the Boundaries Between Salesforce OrgsBlurring the Boundaries Between Salesforce Orgs
Blurring the Boundaries Between Salesforce Orgs
 
Introduction to the Salesforce Security Model
Introduction to the Salesforce Security ModelIntroduction to the Salesforce Security Model
Introduction to the Salesforce Security Model
 
Control your world using the Salesforce1 Platform (IoT)
Control your world using the Salesforce1 Platform (IoT)Control your world using the Salesforce1 Platform (IoT)
Control your world using the Salesforce1 Platform (IoT)
 
What’s new in summer’15 release - Security & Compliance
What’s new in summer’15 release - Security & ComplianceWhat’s new in summer’15 release - Security & Compliance
What’s new in summer’15 release - Security & Compliance
 
What’s new in summer’15 release - Security & Compliance
What’s new in summer’15 release - Security & ComplianceWhat’s new in summer’15 release - Security & Compliance
What’s new in summer’15 release - Security & Compliance
 
Introduction to WebRTC on the Force.com Platform
Introduction to WebRTC on the Force.com PlatformIntroduction to WebRTC on the Force.com Platform
Introduction to WebRTC on the Force.com Platform
 
Secure Salesforce: Org Access Controls
Secure Salesforce: Org Access ControlsSecure Salesforce: Org Access Controls
Secure Salesforce: Org Access Controls
 
Introduction to lightning out df16
Introduction to lightning out   df16Introduction to lightning out   df16
Introduction to lightning out df16
 
MuleSoft Surat Virtual Meetup#24 - MuleSoft and Salesforce Integration and De...
MuleSoft Surat Virtual Meetup#24 - MuleSoft and Salesforce Integration and De...MuleSoft Surat Virtual Meetup#24 - MuleSoft and Salesforce Integration and De...
MuleSoft Surat Virtual Meetup#24 - MuleSoft and Salesforce Integration and De...
 
Salesforce shield & summer 20 release
Salesforce shield & summer 20 releaseSalesforce shield & summer 20 release
Salesforce shield & summer 20 release
 
Securing ap is oauth and fine grained access control
Securing ap is   oauth and fine grained access controlSecuring ap is   oauth and fine grained access control
Securing ap is oauth and fine grained access control
 
Build Consumer-Facing Apps with Heroku Connect
Build Consumer-Facing Apps with Heroku ConnectBuild Consumer-Facing Apps with Heroku Connect
Build Consumer-Facing Apps with Heroku Connect
 
Designing custom REST and SOAP interfaces on Force.com
Designing custom REST and SOAP interfaces on Force.comDesigning custom REST and SOAP interfaces on Force.com
Designing custom REST and SOAP interfaces on Force.com
 
Cache Security- Adding Security to Non-Secure Applications
Cache Security- Adding Security to Non-Secure ApplicationsCache Security- Adding Security to Non-Secure Applications
Cache Security- Adding Security to Non-Secure Applications
 

Recently uploaded

UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
Peter Muessig
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
Philip Schwarz
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
ToXSL Technologies
 
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
gapen1
 
Oracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptxOracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptx
Remote DBA Services
 
一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理
dakas1
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
rodomar2
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
ICS
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
Remote DBA Services
 
14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision
ShulagnaSarkar2
 
The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...
The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...
The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...
kalichargn70th171
 
All you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVMAll you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVM
Alina Yurenko
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Julian Hyde
 
zOS Mainframe JES2-JES3 JCL-JECL Differences
zOS Mainframe JES2-JES3 JCL-JECL DifferenceszOS Mainframe JES2-JES3 JCL-JECL Differences
zOS Mainframe JES2-JES3 JCL-JECL Differences
YousufSait3
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
dakas1
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
Green Software Development
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
Octavian Nadolu
 
What next after learning python programming basics
What next after learning python programming basicsWhat next after learning python programming basics
What next after learning python programming basics
Rakesh Kumar R
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
Green Software Development
 

Recently uploaded (20)

UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
 
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
 
Oracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptxOracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptx
 
一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
 
14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision
 
The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...
The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...
The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...
 
All you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVMAll you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVM
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
 
zOS Mainframe JES2-JES3 JCL-JECL Differences
zOS Mainframe JES2-JES3 JCL-JECL DifferenceszOS Mainframe JES2-JES3 JCL-JECL Differences
zOS Mainframe JES2-JES3 JCL-JECL Differences
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
 
What next after learning python programming basics
What next after learning python programming basicsWhat next after learning python programming basics
What next after learning python programming basics
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
 

Secure Development on the Salesforce Platform - Part 3

  • 2. Speakers Swapnil Shinde Product Security Engineer @Swapnil34 Nitin Arya Product Security Analyst @n_arya0
  • 3. Forward-Looking Statement Statement under the Private Securities Litigation Reform Act of 1995: This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties materialize or if any of the assumptions proves incorrect, the results of salesforce.com, inc. could differ materially from the results expressed or implied by the forward-looking statements we make. All statements other than statements of historical fact could be deemed forward-looking, including any projections of product or service availability, subscriber growth, earnings, revenues, or other financial items and any statements regarding strategies or plans of management for future operations, statements of belief, any statements concerning new, planned, or upgraded services or technology developments and customer contracts or use of our services. The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new functionality for our service, new products and services, our new business model, our past operating losses, possible fluctuations in our operating results and rate of growth, interruptions or delays in our Web hosting, breach of our security measures, the outcome of any litigation, risks associated with completed and any possible mergers and acquisitions, the immature market in which we operate, our relatively limited operating history, our ability to expand, retain, and motivate our employees and manage our growth, new releases of our service and successful customer deployment, our limited history reselling non-salesforce.com products, and utilization and selling to larger enterprise customers. Further information on potential factors that could affect the financial results of salesforce.com, inc. is included in our annual report on Form 10-K for the most recent fiscal year and in our quarterly report on Form 10-Q for the most recent fiscal quarter. These documents and others containing important disclosures are available on the SEC Filings section of the Investor Information section of our Web site. Any unreleased services or features referenced in this or other presentations, press releases or public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make the purchase decisions based upon features that are currently available. Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements.
  • 4. Agenda • Overview - Integrating your external applications securely with Salesforce • Leveraging JavaScript Remoting with Visualforce - Extend Salesforce functionality with external app intergrations - Map user identities to the external systems - Grant access to Salesforce data without breaking security model • Using Remote Objects with Angular.js - Secrets in named credentials - Secrets in custom settings - Proper usage of secrets
  • 5. Building Salesforce Integrations • Extend Salesforce funcationality with external app integrations. • Building data flows and interactions between your external app and Salesforce. • Need a way to map Salesforce user identity to your external system. • Need a way to authenticate and secure data flows between the two systems. • Need a way to grant access to Salesforce data without breaking the Salesforce security model or trust in the Salesforce platform.
  • 6. Integration Methods – Apex Callouts • Use Apex code to access external REST API’s • Can be used to send data out or pull data to/from an external service • Actions must be initiated by a user action from within Salesforce • Partners fail security review here* Salesforce Internet Web service
  • 7. Integration Methods – API/OAuth • Salesforce has several API’s for developers • To use these API’s authentica via - SOAP API username/password login - OAUTH authentication flow • Delegated authentication - Forward username and password ( sent over internet* ) • Federated Authentication using SAML (Single sign on*) Salesforce Web service REST SOA P
  • 8. Integration Methods – API - OAuth • Salesforce has several API’s for developers • External services can authenticate with Salesforce via OAuth and receive access tokens • Tokens must be treated with same sensitivity as a password • Utilize public-facing API’s to share data with Salesforce instances • Developers can expose custom Apex REST endpoints • Outbound messaging SOAP RES T
  • 9. Integration Methods Connected App • Runs on the Salesforce app canvas. • Does not have access to the Salesforce app DOM at any time. • Authenticate via OAuth or SAML using Salesforce credentials. • Easy way to integrate an external application into the Salesforce “skin”. • The OAuth scope for the connected app determines the amount of access this app would have to your Salesforce data. • Make sure to provide least privilege to the OAuth token being created.
  • 10. Integration User or End User Integration User • Creating an integration user to make callouts from the external app into Salesforce. • Lets you create a least privilege integration user to perform certain operations required by the app. • You don’t have to provide API access to all users. • Only on credential to manage on the external system. • You have to make sure that the Salesforce security model is not broken when the external system accesses Salesforce data.
  • 11. Integration User or End User End User • Lets your external app make requests as current logged in user with the specified OAuth scope. • Lets the user select if they want to allow or access or not. • Preserves the Salesforce security model in your external requests without any additional measures. • The external app needs to make sure all end user OAuth credentials are stored secureon the external system.
  • 12. Setting Up A Connected App Go to Setup > Create > Apps > New Connected App
  • 13. Setting Up A Connected App
  • 14. Advantages of Connected Apps • No need for custom authentication logic. • Least privilege access control based on the external app use case. • Easy to revoke access for misbehaving apps. • Out of box functionality for standard Auth protocols. • Can provide access without sharing Salesforce username password with the external app.
  • 15. Credential Handling • External app credentials (consumer key/secret) should be stored securely off the Salesforce platform. • Salesforce OAuth tokens should be stored securely off the platform using the industry best practice for your development platform. • API tokens for the external app should be stored via Protected custom settings inside Salesforce. • All credentials should be secure in transit by using HTTPS (TLS) for all communications.
  • 16. Transport Security Security Expectations of HTTP • None. • Anyone on the network can eavesdrop traffic. • Anyone on the network can modify content. • Anyone on the network can divert traffic.
  • 17. Transport Security – What is TLS? • A user visiting a site over HTTP has no assurance that the user is interacting with the legitimate site. • The Transport Layer Security protocol allows for secure communication between applications and users. • Uses PKI (Public Key Infrastructure) to have a Trusted Certificate Authority (CA) vouch for the server’s identity. • Prevents tampering, eavesdropping, and man-in-the- middle attacks against secure communications. Provides authentication and confidentiality.
  • 18. Mutual TLS • Salesforce supports Mutual TLS for communications between Salesforce and your external server. • This allows you to do a two-way verification, where the client and server can confirm one another’s identity. • Good for server to server authentication, where the client is not prompting a user to log in manually.
  • 20. Salesforce Mutual TLS • Client certificates are uploaded and stored in the Salesforce database, where they are used for verification. • You can also download the Salesforce client certificate to authenticate on your web server, when making Apex callouts, etc. • Salesforce provides a mechanism to prevent falling back to the standard TLS port.
  • 21. Setting Up Mutual TLS • Have mutual TLS enabled for your organization. • Generate Certificate Signing Request (CSR) and acquire a certificate form a Trusted CA.
  • 22. Salesforce Mutual TLS • Upload the certificate to Security Controls | Certificate and Key Management. • Enable “Enforce SSL/TLS Mutual Authentication” permission for the API client user. This will force mutual TLS on port 8443 for this user. • This user permission can be added via a PermSet or by adding the permission to the user profile. • Configure the API client to connect on port 8443 and present the client certificate.
  • 24. Why Use Mutual TLS? • This seems like a lot of work! Why should I do this? • Provides you a good way to authenticate both parties (Salesforce and external app) when building external integrations. • You don’t just have to rely on IP range restrictions and static API keys for client authentication. • Out of the box mutual TLS implementation provides authentication and confidentiality.
  • 26. Primary Topic Today: Secrets • We will be covering developer-oriented topics on secret storage for the Salesforce Platform. • Specific features to cover include: – Secrets in named credentials – Secrets in custom settings – Proper secret usage – Protected Custom Metadata Types ??????????? • Useful for anyone in the following areas: – Salesforce Developers (primarily) – Salesforce Administrators – Prospective Partners
  • 27. What is a secret? • Simple Definition: A piece of data that requires higher than normal protection. • For Our Purposes: A secret will be a piece of data that nobody should see, like a password or encryption key.
  • 28. Who do we secure secrets from? • Attackers • Regular Users • Partners • Administrators (Biggest Challenge) • Basically, everyone… Why? • Theft of data • Impersonation • Privilege Escalation
  • 29. Secret in Named Credentials
  • 30. Named Credentials Overview Named crewdentials are a feature for secret storage built into the Salesforce platform. • Available in the “Security” setup menu • Point & click creation • No Code required to store secret
  • 31. Named Credentials - Usage • Create a new named credential • Add the URL + secret to the named credential • Invoke the named credential in the httpRequest HttpRequest req = new HttpRequest(); req.setEndpoint('callout:NamedCredential'); req.setMethod('GET'); Http http = new Http(); HTTPResponse res = http.send(req); return res.getBody();
  • 32. Pros • Easy to create. • Easy to invoke. • Secret is not visible in the UI and code to anyone. • Secret is not leaked in the debug logs. Cons • Only works for httpRequests and certain authentication schemes like OAuth 2.0. • URL can be updated in the setup, potentially leaking secret. ??? Named Credentials - Breakdown
  • 33. Demo: Secrets in Named Credentials
  • 34. Custom Settings Overview Custom settings are stripped down sObjects exposed to the application cache, enabling efficient access for developers. Protected versus Public: What is the difference? Protected Custom Settings can only be accessed from the namespace they exist in. • In a managed package, the namespace is that of the package. • In an unmanaged package, the namespace is the local namespace (so no effect). What does this mean? • Managed protected Custom Settings – Extra Security Benefits • Managed Public/ Local Public/ Local Protected – No security benefits, worse for secrets than sObjects.
  • 35. Managed Protected Custom Settings – Storage Method 1. Create a managed package. 2. Create a protected custom setting inside the package. 3. Create a Visualforce page inside the package to create/update the secret. - Transient string (in controller), should not return secret to the view state. 4. Access and use the secret inside the managed package.
  • 37. Pros • Secret only available to Apex code within managed package namespace. • Can store encryption key to scale. Cons • Requires a managed package! • Methods must be well-coded to prevent secret exposure. Managed Protected Custom Setting - Breakdown
  • 39. Demo: Secrets in Custom Settings
  • 40. Using Managed Protected Custom Settings Properly
  • 41. Overview Using Managed Protected Custom Settings Properly Secret storage solutions with managed protected custom settings are developed in Apex and Visualforce, and because of this there are some best practices that must be followed: • Properly encapsulating secret usage in the managed package • Properly handling secret dependencies • Avoiding secret reflection
  • 42. Properly Encapsulating Secret Usage What is encapsulation? Keeping functionality inside the managed package. Why encapsulate? Namespace benefits on work INSIDE the managed package. Anything leaving the package loses benefits. Things to consider for encapsulation: • User interaction - Visualforce page/component inside the managed package. • Using the secret – Code must be contained within the managed package. • Invoking secret usage - Done with a global method, secret never returned outside of the managed package.
  • 44. Properly Handling Secret Dependencies What are secret dependencies? If a secret is tied to another piece of information, a dependency is created. Examples: • Passwords can be dependent on URLs. • Encryption keys can be dependent on Salts. Secret dependency best practices: • Secrets and dependencies are controlled from the same place • If dependent is updated, secret should be updated. This prevents the attacker from gaining additional information. • Example: If a URL is updated, password should change too!
  • 45. Avoiding Secret Reflection What is secret reflection? Developers often mistakenly allow a secret to be reflected from the controller (Apex) to the view (Visualforce). Since the view is client side, the risk of secret exposure increases dramatically! Secret reflection Best Practices • Beware hidden inputs – hidden inputs often show secret in clear within source. • Use transient keyword – transient keyword prevents secret from being stored in the Visualforce viewstate.
  • 47. Recap 1. Named Credentials • Pro – Simple. No secret refelcted in UI or debug logs. • Con – URL can be changed and secret leaked, only works with httpRequests. - Works well with: Passwords and OAuth tokens that don’t come with admin privileges. 2. Managed Protected Custom Setting (Secret Storage Best Practice) • Pro – Most secure option. Protects against users with elevated permissions such as Modify all Data. • Con – Requires a managed package. Requires careful attention to code (see below). - Works well with: Passwords, OAuth tokens, Encryption keys. 3. Using Managed Protected Custom Settings Properly • Properly encapsulating secret usage in the managed package. • Properly handling secret dependencies (update password when updating URL). • Avoiding secret reflection (beware hidden inputs use transient keyword).
  • 48. Additional Resources • Secure Coding Guidelines - https:/ developer.salesforce.com/page/Secure_Coding_Storing_Secrets • Intro to Managed Packages - https://developer.salesforce.com/page/An_Introduction_to_Packaging • Salesforce StackExchange – http://salesforce.stackexchange.com/questions/tagged/security • Developer.Salesforce.com Security Forum - https://developer.salesforce.com/forums (full link hidden) • Security Office Hours (Partners) - http://security.force.com/security/contact/ohours • Security Implementation Guide - https://developer.salesforce.com/././securityImplGuide/ (full link hidden) • Force.com Security Essentials Course - https://trustacademy.salesforce.com
  • 50.
  • 51. Additional Resources • Digging deep into Oauth 2.0 • Salesforce trust academy • Salesforce generate CSR • Salesforce mutual TLS setup • Salesforce connected apps
  • 52. Q & A Try Trailhead: trailhead.salesforce.com Join the conversation: @salesforcedevs