SlideShare une entreprise Scribd logo
1  sur  41
Télécharger pour lire hors ligne
SECURING YOUR
PLUGIN
Penny Wyatt
Atlassian QA
Topics
 Cross-Site Scripting (XSS) Vulnerabilities
 Cross-Site Request Forgery (XSRF)
Vulnerabilities
 Confluence WebSudo
 File Execution Vulnerabilities
 Random Number Vulnerabilities
Cross Site Scripting
(XSS) Vulnerabilities
XSS Vulnerabilities
 Attacker runs JavaScript in the victim’s
web browser.
 Attacker can do anything the victim can.
 Two types:
 Persisted XSS
 Reflected XSS
Persisted XSS Vulnerabilities
 Attacker enters malicious data which is
stored on the server.
 The data are presented on a page,
unescaped.
 Requires the attacker to have
permission to insert data.
 Doesn’t require any action on the
victim’s part.
Reflected XSS Vulnerabilities
 Attack is inserted into a URL.
 Value from the querystring is reflected
directly onto the page, not stored.
 Attacker gets the victim to visit the URL.
 Does not require the attacker to have
any access at all.
 Requires some minor social
engineering.
Fixing XSS Vulnerabilities
 Where the value is inserted into plain HTML,
use HTML encoding.
 JIRA - $textutils.htmlEncode($name)
 Confluence - $generalUtil.htmlEncode($name)
 Bamboo - ${name?html}
Fixing XSS Vulnerabilities
 Where the value is inserted into JavaScript,
HTML escaping is insufficient...
Fixing XSS Vulnerabilities
 JavaScript escaping is also dangerous.
 Better approach – insert escaped value
into HTML and access via the DOM.
Fixing XSS Vulnerabilities
 Never insert user-supplied content
directly into JavaScript.
 Also includes other script execution
methods
 When feasible, restrict data server-side
Fixing XSS Vulnerabilities
 Only escape at the Velocity level, never
internally.
 Strict boundary for safe/unsafe content.
 Reduce risk of double-escaping.
Confluence Anti-XSS
 Opt-in auto-escaping for Velocity
templates in Confluence.
 Since Confluence 2.9.
 Only partial protection.
 Some areas still at risk:
 HTML generated by excluded methods.
 HTML generated client-side.
 User-supplied variables inserted into
JavaScript.
Finding XSS Vulnerabilities
 Manual code analysis
 Read velocity templates, webwork,
Confluence macros, any other source of
HTML.
 Trace the source of all parameters.
Finding XSS Vulnerabilities
 Manual UI testing
 Enter unsafe data in all form fields, including
hidden fields.
 Enter unsafe data into all URL parameters.
 Watch for unexpected behaviour.
Finding XSS Vulnerabilities
 Automated Scanning tools
 Burp Suite, Skipfish
 Useful to catch obvious flaws.
 Lots of false positives, missed
vulnerabilities.
Cross Site
Request Forgery
(XSRF) Vulnerabilities
XSRF Vulnerabilities
 Attacker tricks victim into executing an
action.
 Action can be performed merely by
visiting an URL.
 Request is hidden on an unrelated page
or used in conjunction with an XSS
vulnerabilities.
 Victim may be unaware of the action.
XSRF Vulnerabilities
XSRF Vulnerabilities
XSRF Vulnerabilities
 Can vote for a JIRA issue by visiting a
URL.
https://extranet.atlassian.com/jira/secure/
VoteOrWatchIssue.jspa?id=19128&vote=vote
 No XSRF protection in those days.
 Embedded image on another page
<img src=
“https://extranet.atlassian.com/jira/secure/
VoteOrWatchIssue.jspa?id=19128&vote=vote”>
XSRF Vulnerabilities
Fixing XSRF Vulnerabilities
 Limited-duration token issued by server.
 Must provide that token when performing
protected actions.
 User can manually confirm an action if
token has expired.
 Since Confluence 3.0, JIRA 4.1.
Fixing XSRF Vulnerabilities
 Step 1 (JIRA): Add
@RequiresXsrfCheck to doExecute().
Fixing XSRF Vulnerabilities
 Step 1 (Confluence): Add
@RequireSecurityToken(true) to
doExecute().
Fixing XSRF Vulnerabilities
 Step 2: Add token to forms and querystrings.
JIRA:
Confluence:
Finding XSRF Vulnerabilities
 Every action that changes the state of
the plugin or host application is
vulnerable.
 Overuse of XSRF protection frustrates
users.
 XSRF protection easily circumvented by
XSS.
Confluence WebSudo
Confluence WebSudo
 Aka “Secure Administrator Sessions”
 Second line of defence against XSS and
XSRF attacks in Confluence.
 Protects administration functions by
requiring a second login into an
administrative mode.
 Default 10 minute rolling timeout.
 Since Confluence 3.3.
Confluence WebSudo
 @WebSudoRequired annotation
 Can be disabled by sysadmins
 Narrows the window in which a stolen
cookie can be used to perform admin
functions, but does not eliminate it.
 Disabled in dev mode.
File Execution
Vulnerabilities
File Execution
Vulnerabilities
 Allowing a user or administrator to
access an arbitrary location on the file
system is dangerous.
 Simplest exploit – get Tomcat to serve
an uploaded file.
 Escalation of privileges.
Fixing File Execution
Vulnerabilities
 Never allow administrators or users to
specify server file paths through the UI.
 Use known safe directories.
 If configuration is absolutely necessary,
store the path in a .properties file on the
server.
Random Number
Vulnerabilities
Random Number Vulnerabilities
 Random numbers are often used for
security, e.g.
 XSRF tokens.
 Reset password tokens.
 If you can predict them, you can break
them.
 java.util.Random is not secure.
 Given one value, you can predict the
next.
Random Number Vulnerabilities
Random Number Vulnerabilities
 java.security.SecureRandom is better
 Still can be misused.
 Predictable seeding (e.g. with the
system time) generates predictable
values.
Random Number Vulnerabilities
Fixing Random Number
Vulnerabilities
 atlassian-secure-random package.
 Facade for SecureRandom that correctly
instantiates and seeds it.
 Allows for future performance and
cryptographic improvements with no
future code change required.
Fixing Random Number
Vulnerabilities
 Step 1: Add dependency to the pom:
 Step 2: Get the instance, then use in the
same way as a SecureRandom:
Best Coding Practices
 HTML-encode user values in Velocity.
 Don’t insert user values into JavaScript.
 XSRF-protect functions.
 Use WebSudo for admin functions in
Confluence.
 Restrict file system access to known
safe directories.
 Use atlassian-secure-random
Q&A

Contenu connexe

Tendances

Cross Site Request Forgery Vulnerabilities
Cross Site Request Forgery VulnerabilitiesCross Site Request Forgery Vulnerabilities
Cross Site Request Forgery Vulnerabilities
Marco Morana
 
Stateless Anti-Csrf
Stateless Anti-CsrfStateless Anti-Csrf
Stateless Anti-Csrf
johnwilander
 

Tendances (20)

RailsConf 2015 - Metasecurity: Beyond Patching Vulnerabilities
RailsConf 2015 - Metasecurity: Beyond Patching VulnerabilitiesRailsConf 2015 - Metasecurity: Beyond Patching Vulnerabilities
RailsConf 2015 - Metasecurity: Beyond Patching Vulnerabilities
 
Grey H@t - Cross-site Request Forgery
Grey H@t - Cross-site Request ForgeryGrey H@t - Cross-site Request Forgery
Grey H@t - Cross-site Request Forgery
 
Cross site scripting XSS
Cross site scripting XSSCross site scripting XSS
Cross site scripting XSS
 
Xss (cross site scripting)
Xss (cross site scripting)Xss (cross site scripting)
Xss (cross site scripting)
 
GoSec 2015 - Protecting the web from within
GoSec 2015 - Protecting the web from withinGoSec 2015 - Protecting the web from within
GoSec 2015 - Protecting the web from within
 
Common hacking practices
Common hacking practicesCommon hacking practices
Common hacking practices
 
Reflective and Stored XSS- Cross Site Scripting
Reflective and Stored XSS- Cross Site ScriptingReflective and Stored XSS- Cross Site Scripting
Reflective and Stored XSS- Cross Site Scripting
 
Php security common 2011
Php security common 2011Php security common 2011
Php security common 2011
 
Introduction to CSRF Attacks & Defense
Introduction to CSRF Attacks & DefenseIntroduction to CSRF Attacks & Defense
Introduction to CSRF Attacks & Defense
 
Understanding CSRF
Understanding CSRFUnderstanding CSRF
Understanding CSRF
 
Cross-Site Request Forgery Vulnerability: “A Sleeping Giant”
Cross-Site Request Forgery Vulnerability: “A Sleeping Giant”Cross-Site Request Forgery Vulnerability: “A Sleeping Giant”
Cross-Site Request Forgery Vulnerability: “A Sleeping Giant”
 
Cross Site Request Forgery Vulnerabilities
Cross Site Request Forgery VulnerabilitiesCross Site Request Forgery Vulnerabilities
Cross Site Request Forgery Vulnerabilities
 
Intro to Web Application Security
Intro to Web Application SecurityIntro to Web Application Security
Intro to Web Application Security
 
Security testing for web developers
Security testing for web developersSecurity testing for web developers
Security testing for web developers
 
Stateless Anti-Csrf
Stateless Anti-CsrfStateless Anti-Csrf
Stateless Anti-Csrf
 
CROSS-SITE REQUEST FORGERY - IN-DEPTH ANALYSIS 2011
CROSS-SITE REQUEST FORGERY - IN-DEPTH ANALYSIS 2011CROSS-SITE REQUEST FORGERY - IN-DEPTH ANALYSIS 2011
CROSS-SITE REQUEST FORGERY - IN-DEPTH ANALYSIS 2011
 
Cross Site Request Forgery
Cross Site Request ForgeryCross Site Request Forgery
Cross Site Request Forgery
 
Cross site scripting
Cross site scriptingCross site scripting
Cross site scripting
 
Understanding Cross-site Request Forgery
Understanding Cross-site Request ForgeryUnderstanding Cross-site Request Forgery
Understanding Cross-site Request Forgery
 
A7 Missing Function Level Access Control
A7   Missing Function Level Access ControlA7   Missing Function Level Access Control
A7 Missing Function Level Access Control
 

Similaire à AtlasCamp 2010: Securing your Plugin - Penny Wyatt

Cross Site Scripting
Cross Site ScriptingCross Site Scripting
Cross Site Scripting
Ali Mattash
 
xss-100908063522-phpapp02.pdf
xss-100908063522-phpapp02.pdfxss-100908063522-phpapp02.pdf
xss-100908063522-phpapp02.pdf
yashvirsingh48
 
Web 2.0 Application Kung-Fu - Securing Ajax & Web Services
Web 2.0 Application Kung-Fu - Securing Ajax & Web ServicesWeb 2.0 Application Kung-Fu - Securing Ajax & Web Services
Web 2.0 Application Kung-Fu - Securing Ajax & Web Services
Shreeraj Shah
 

Similaire à AtlasCamp 2010: Securing your Plugin - Penny Wyatt (20)

Introduction to Cross Site Scripting ( XSS )
Introduction to Cross Site Scripting ( XSS )Introduction to Cross Site Scripting ( XSS )
Introduction to Cross Site Scripting ( XSS )
 
Cross Site Scripting
Cross Site ScriptingCross Site Scripting
Cross Site Scripting
 
Session7-XSS & CSRF
Session7-XSS & CSRFSession7-XSS & CSRF
Session7-XSS & CSRF
 
Cross Site Scripting ( XSS)
Cross Site Scripting ( XSS)Cross Site Scripting ( XSS)
Cross Site Scripting ( XSS)
 
Antiviruxss
AntiviruxssAntiviruxss
Antiviruxss
 
Owasp Top 10 - Owasp Pune Chapter - January 2008
Owasp Top 10 - Owasp Pune Chapter - January 2008Owasp Top 10 - Owasp Pune Chapter - January 2008
Owasp Top 10 - Owasp Pune Chapter - January 2008
 
XSS-Alert-Pentration testing tool
XSS-Alert-Pentration testing toolXSS-Alert-Pentration testing tool
XSS-Alert-Pentration testing tool
 
04. xss and encoding
04.  xss and encoding04.  xss and encoding
04. xss and encoding
 
xss-100908063522-phpapp02.pdf
xss-100908063522-phpapp02.pdfxss-100908063522-phpapp02.pdf
xss-100908063522-phpapp02.pdf
 
Understanding dom based xss
Understanding dom based xssUnderstanding dom based xss
Understanding dom based xss
 
4.Xss
4.Xss4.Xss
4.Xss
 
XSS.pdf
XSS.pdfXSS.pdf
XSS.pdf
 
XSS.pdf
XSS.pdfXSS.pdf
XSS.pdf
 
Cross Site Scripting(XSS)
Cross Site Scripting(XSS)Cross Site Scripting(XSS)
Cross Site Scripting(XSS)
 
Cross Site Scripting Defense Presentation
Cross Site Scripting Defense Presentation Cross Site Scripting Defense Presentation
Cross Site Scripting Defense Presentation
 
Web 2.0 Application Kung-Fu - Securing Ajax & Web Services
Web 2.0 Application Kung-Fu - Securing Ajax & Web ServicesWeb 2.0 Application Kung-Fu - Securing Ajax & Web Services
Web 2.0 Application Kung-Fu - Securing Ajax & Web Services
 
IRJET- A Survey on Various Cross-Site Scripting Attacks and Few Prevention Ap...
IRJET- A Survey on Various Cross-Site Scripting Attacks and Few Prevention Ap...IRJET- A Survey on Various Cross-Site Scripting Attacks and Few Prevention Ap...
IRJET- A Survey on Various Cross-Site Scripting Attacks and Few Prevention Ap...
 
CROSS SITE SCRIPTING.ppt
CROSS SITE SCRIPTING.pptCROSS SITE SCRIPTING.ppt
CROSS SITE SCRIPTING.ppt
 
React security vulnerabilities
React security vulnerabilitiesReact security vulnerabilities
React security vulnerabilities
 
Deep understanding on Cross-Site Scripting and SQL Injection
Deep understanding on Cross-Site Scripting and SQL InjectionDeep understanding on Cross-Site Scripting and SQL Injection
Deep understanding on Cross-Site Scripting and SQL Injection
 

Plus de Atlassian

Design Your Next App with the Atlassian Vendor Sketch Plugin
Design Your Next App with the Atlassian Vendor Sketch PluginDesign Your Next App with the Atlassian Vendor Sketch Plugin
Design Your Next App with the Atlassian Vendor Sketch Plugin
Atlassian
 

Plus de Atlassian (20)

International Women's Day 2020
International Women's Day 2020International Women's Day 2020
International Women's Day 2020
 
10 emerging trends that will unbreak your workplace in 2020
10 emerging trends that will unbreak your workplace in 202010 emerging trends that will unbreak your workplace in 2020
10 emerging trends that will unbreak your workplace in 2020
 
Forge App Showcase
Forge App ShowcaseForge App Showcase
Forge App Showcase
 
Let's Build an Editor Macro with Forge UI
Let's Build an Editor Macro with Forge UILet's Build an Editor Macro with Forge UI
Let's Build an Editor Macro with Forge UI
 
Meet the Forge Runtime
Meet the Forge RuntimeMeet the Forge Runtime
Meet the Forge Runtime
 
Forge UI: A New Way to Customize the Atlassian User Experience
Forge UI: A New Way to Customize the Atlassian User ExperienceForge UI: A New Way to Customize the Atlassian User Experience
Forge UI: A New Way to Customize the Atlassian User Experience
 
Take Action with Forge Triggers
Take Action with Forge TriggersTake Action with Forge Triggers
Take Action with Forge Triggers
 
Observability and Troubleshooting in Forge
Observability and Troubleshooting in ForgeObservability and Troubleshooting in Forge
Observability and Troubleshooting in Forge
 
Trusted by Default: The Forge Security & Privacy Model
Trusted by Default: The Forge Security & Privacy ModelTrusted by Default: The Forge Security & Privacy Model
Trusted by Default: The Forge Security & Privacy Model
 
Designing Forge UI: A Story of Designing an App UI System
Designing Forge UI: A Story of Designing an App UI SystemDesigning Forge UI: A Story of Designing an App UI System
Designing Forge UI: A Story of Designing an App UI System
 
Forge: Under the Hood
Forge: Under the HoodForge: Under the Hood
Forge: Under the Hood
 
Access to User Activities - Activity Platform APIs
Access to User Activities - Activity Platform APIsAccess to User Activities - Activity Platform APIs
Access to User Activities - Activity Platform APIs
 
Design Your Next App with the Atlassian Vendor Sketch Plugin
Design Your Next App with the Atlassian Vendor Sketch PluginDesign Your Next App with the Atlassian Vendor Sketch Plugin
Design Your Next App with the Atlassian Vendor Sketch Plugin
 
Tear Up Your Roadmap and Get Out of the Building
Tear Up Your Roadmap and Get Out of the BuildingTear Up Your Roadmap and Get Out of the Building
Tear Up Your Roadmap and Get Out of the Building
 
Nailing Measurement: a Framework for Measuring Metrics that Matter
Nailing Measurement: a Framework for Measuring Metrics that MatterNailing Measurement: a Framework for Measuring Metrics that Matter
Nailing Measurement: a Framework for Measuring Metrics that Matter
 
Building Apps With Color Blind Users in Mind
Building Apps With Color Blind Users in MindBuilding Apps With Color Blind Users in Mind
Building Apps With Color Blind Users in Mind
 
Creating Inclusive Experiences: Balancing Personality and Accessibility in UX...
Creating Inclusive Experiences: Balancing Personality and Accessibility in UX...Creating Inclusive Experiences: Balancing Personality and Accessibility in UX...
Creating Inclusive Experiences: Balancing Personality and Accessibility in UX...
 
Beyond Diversity: A Guide to Building Balanced Teams
Beyond Diversity: A Guide to Building Balanced TeamsBeyond Diversity: A Guide to Building Balanced Teams
Beyond Diversity: A Guide to Building Balanced Teams
 
The Road(map) to Las Vegas - The Story of an Emerging Self-Managed Team
The Road(map) to Las Vegas - The Story of an Emerging Self-Managed TeamThe Road(map) to Las Vegas - The Story of an Emerging Self-Managed Team
The Road(map) to Las Vegas - The Story of an Emerging Self-Managed Team
 
Building Apps With Enterprise in Mind
Building Apps With Enterprise in MindBuilding Apps With Enterprise in Mind
Building Apps With Enterprise in Mind
 

Dernier

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Dernier (20)

[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 

AtlasCamp 2010: Securing your Plugin - Penny Wyatt

  • 2. Topics  Cross-Site Scripting (XSS) Vulnerabilities  Cross-Site Request Forgery (XSRF) Vulnerabilities  Confluence WebSudo  File Execution Vulnerabilities  Random Number Vulnerabilities
  • 3. Cross Site Scripting (XSS) Vulnerabilities
  • 4. XSS Vulnerabilities  Attacker runs JavaScript in the victim’s web browser.  Attacker can do anything the victim can.  Two types:  Persisted XSS  Reflected XSS
  • 5. Persisted XSS Vulnerabilities  Attacker enters malicious data which is stored on the server.  The data are presented on a page, unescaped.  Requires the attacker to have permission to insert data.  Doesn’t require any action on the victim’s part.
  • 6. Reflected XSS Vulnerabilities  Attack is inserted into a URL.  Value from the querystring is reflected directly onto the page, not stored.  Attacker gets the victim to visit the URL.  Does not require the attacker to have any access at all.  Requires some minor social engineering.
  • 7. Fixing XSS Vulnerabilities  Where the value is inserted into plain HTML, use HTML encoding.  JIRA - $textutils.htmlEncode($name)  Confluence - $generalUtil.htmlEncode($name)  Bamboo - ${name?html}
  • 8. Fixing XSS Vulnerabilities  Where the value is inserted into JavaScript, HTML escaping is insufficient...
  • 9. Fixing XSS Vulnerabilities  JavaScript escaping is also dangerous.  Better approach – insert escaped value into HTML and access via the DOM.
  • 10. Fixing XSS Vulnerabilities  Never insert user-supplied content directly into JavaScript.  Also includes other script execution methods  When feasible, restrict data server-side
  • 11. Fixing XSS Vulnerabilities  Only escape at the Velocity level, never internally.  Strict boundary for safe/unsafe content.  Reduce risk of double-escaping.
  • 12. Confluence Anti-XSS  Opt-in auto-escaping for Velocity templates in Confluence.  Since Confluence 2.9.  Only partial protection.  Some areas still at risk:  HTML generated by excluded methods.  HTML generated client-side.  User-supplied variables inserted into JavaScript.
  • 13. Finding XSS Vulnerabilities  Manual code analysis  Read velocity templates, webwork, Confluence macros, any other source of HTML.  Trace the source of all parameters.
  • 14. Finding XSS Vulnerabilities  Manual UI testing  Enter unsafe data in all form fields, including hidden fields.  Enter unsafe data into all URL parameters.  Watch for unexpected behaviour.
  • 15. Finding XSS Vulnerabilities  Automated Scanning tools  Burp Suite, Skipfish  Useful to catch obvious flaws.  Lots of false positives, missed vulnerabilities.
  • 17. XSRF Vulnerabilities  Attacker tricks victim into executing an action.  Action can be performed merely by visiting an URL.  Request is hidden on an unrelated page or used in conjunction with an XSS vulnerabilities.  Victim may be unaware of the action.
  • 20. XSRF Vulnerabilities  Can vote for a JIRA issue by visiting a URL. https://extranet.atlassian.com/jira/secure/ VoteOrWatchIssue.jspa?id=19128&vote=vote  No XSRF protection in those days.  Embedded image on another page <img src= “https://extranet.atlassian.com/jira/secure/ VoteOrWatchIssue.jspa?id=19128&vote=vote”>
  • 22. Fixing XSRF Vulnerabilities  Limited-duration token issued by server.  Must provide that token when performing protected actions.  User can manually confirm an action if token has expired.  Since Confluence 3.0, JIRA 4.1.
  • 23. Fixing XSRF Vulnerabilities  Step 1 (JIRA): Add @RequiresXsrfCheck to doExecute().
  • 24. Fixing XSRF Vulnerabilities  Step 1 (Confluence): Add @RequireSecurityToken(true) to doExecute().
  • 25. Fixing XSRF Vulnerabilities  Step 2: Add token to forms and querystrings. JIRA: Confluence:
  • 26. Finding XSRF Vulnerabilities  Every action that changes the state of the plugin or host application is vulnerable.  Overuse of XSRF protection frustrates users.  XSRF protection easily circumvented by XSS.
  • 28. Confluence WebSudo  Aka “Secure Administrator Sessions”  Second line of defence against XSS and XSRF attacks in Confluence.  Protects administration functions by requiring a second login into an administrative mode.  Default 10 minute rolling timeout.  Since Confluence 3.3.
  • 29. Confluence WebSudo  @WebSudoRequired annotation  Can be disabled by sysadmins  Narrows the window in which a stolen cookie can be used to perform admin functions, but does not eliminate it.  Disabled in dev mode.
  • 31. File Execution Vulnerabilities  Allowing a user or administrator to access an arbitrary location on the file system is dangerous.  Simplest exploit – get Tomcat to serve an uploaded file.  Escalation of privileges.
  • 32. Fixing File Execution Vulnerabilities  Never allow administrators or users to specify server file paths through the UI.  Use known safe directories.  If configuration is absolutely necessary, store the path in a .properties file on the server.
  • 34. Random Number Vulnerabilities  Random numbers are often used for security, e.g.  XSRF tokens.  Reset password tokens.  If you can predict them, you can break them.  java.util.Random is not secure.  Given one value, you can predict the next.
  • 36. Random Number Vulnerabilities  java.security.SecureRandom is better  Still can be misused.  Predictable seeding (e.g. with the system time) generates predictable values.
  • 38. Fixing Random Number Vulnerabilities  atlassian-secure-random package.  Facade for SecureRandom that correctly instantiates and seeds it.  Allows for future performance and cryptographic improvements with no future code change required.
  • 39. Fixing Random Number Vulnerabilities  Step 1: Add dependency to the pom:  Step 2: Get the instance, then use in the same way as a SecureRandom:
  • 40. Best Coding Practices  HTML-encode user values in Velocity.  Don’t insert user values into JavaScript.  XSRF-protect functions.  Use WebSudo for admin functions in Confluence.  Restrict file system access to known safe directories.  Use atlassian-secure-random
  • 41. Q&A