SlideShare uma empresa Scribd logo
1 de 17
Baixar para ler offline
SSO Vulnerabilities
Tarachand Verma
Identity Access And Management Lead
What is Single Sign On
App1
App3
App2
Identity Provider
(IdP)
login
login
login
Responsibility
- Presents login page
- Verifies credentials
- Creates and maintain user sso session
- Returns identity to app securely
- Skip login page if user already has session
User
credentials
Database
Most popular SSO protocols
- SAML
- OpenID-Connect
send identity to app securely
Internal DB call
SAML SSO
Service Provider
(SP)
Identity Provider
(IdP)login
Responsibility
- Presents login page
- Verifies credentials
- Creates and maintain user session
- Returns identity to app using
signed/encrypted SAML response
- Skip login page if user already has session
on subsequent login requests
User
credentials
Database
Examples
www.example.com(SP) → google.com( IdP)
SAML2
SP_acs?SAMLResponse=signed_or_encrypted(identity)
SAML Response (abbreviated)
<saml:Assertion ID="123">
<saml:Issuer>google.com</saml:Issuer>
<saml:Subject>
<saml:NameID>john.doe@example.com</saml:NameID>
</saml:Subject>
<saml:Conditions
NotBefore="2018-08-20T00:00:00Z"
NotOnOrAfter="2018-08-21T00:00:00Z">
<saml:AudienceRestriction>
<saml:Audience>www.example.com</saml:Audience>
</saml:AudienceRestriction>
</saml:Conditions>
</saml:Assertion>
SAML SSO bypass vulnerability
● Service Provider relies on Subject/NameID and Assertions to
know the who the user is to create SP session.
● Service Provider uses various SAML libraries to parse SAML
response ( XML Formatted )
● Attacker exploits two issues to manipulate parsed data
1) XML parsing issue
2) Cryptographic signing issue
Issue #1 - XML Parsing Issue
XML
<saml:NameID>not-a-cto@example.com</saml:NameID>
Parsed
NameID
|_ Text: not-a-cto@example.com
XML
<saml:NameID>not-a-<!-- this is a comment -->cto@example.com</saml:NameID>
Parsed
NameID
|_ Text: not-a-
|_ Comment: this is a comment
|_ Text: cto@example.com → here is the vulnerability
Issue #2 - Cryptographic signing
Both XML will have same cryptographic signature
<p> hello </p>
And
<p>hello</p>
Reason: because XML doesn’t care about whitespace.
When the XML document is analyzed before a signature is created, space is removed.
Its called canonicalization.
Most canonicalization algorithms also don’t care about comments → vulnerability
That means both will have same signature.
<saml:NameID>not-a-<!-- this is a comment -->cto@example.com</saml:NameID>
And
<saml:NameID>not-a-cto@example.com</saml:NameID>
SAML Response with Canonicalization algo
<SAMLResponse>
<Issuer>https://google.com/</Issuer>
<Assertion ID="_id1234">
<Subject>
<NameID>non-a-cto@example.com</NameID>
</Subject>
</Assertion>
<Signature>
<SignedInfo>
<CanonicalizationMethod Algorithm="xml-c14n11"/>
<Reference URI="#_id1234"/>
</SignedInfo>
<SignatureValue>
some base64 data that represents the signature of the assertion
</SignatureValue>
</Signature>
</SAMLResponse>
How attacker exploits
Precondition
a) Attacker owns his own account at Identity Provider AND
b) Knows what’s canonicalization
Steps
1) Attacker creates/has an account with emailAddress - not-a-cto@example.com
2) Attacker logs in the IdP i.e. Example.com and updates his own emailAddress to
not-a-<!-- this is a comment -->cto@example.com
3) Attacker logs out and logs back in which generates SAML response with comments to exploit XML parsing
vulnerability
OR
1) Attacker creates/has an account with emailAddress - not-a-cto@example.com
2) Attacker logs in the IdP and grabs SAML response and updates assertion to
not-a-<!-- this is a comment -->cto@example.com
4) Replays SAML response to exploit weak XML canonicalization vulnerability
How to prevent exploitation
● Avoid SAML and use more modern OpenID-Connect which doesn’t use XML
● Check your SAML library and dependent XML parsing and signature verification
libraries and check for vulnerabilities.
● As an IdP, purge comments while creating XML documents
● As an SP, reject any SAML attribute if XML attribute node contains more than one
child.
● Use canonicalization algorithm which doesn’t remove comments while generating
signature - http://www.w3.org/2001/10/xml-exc-c14n#WithComments
Affected ones
● OneLogin’s python-saml,
● OneLogin’s ruby-saml,
● Clever’s saml2,
● omniauth-saml, and
● Shibboleth’s openSAML C++
OpenID-Connect
App
(RP aka Relying Party)
OpenID-Connect
Provider
(OP)
login
Responsibility
- Presents login page
- Verifies credentials
- Creates and maintain user session
- Returns identity to app using signed id_token
response(JWT formatted)
- Skip login page if user already has session
on subsequent login requests
User
credentials
Database
Examples
www.example.com(RP) → accounts.google.com( OP)
OpenID
RP_callback?id_token=signed(identity)
id_token (JWT formatted)
● id_token represents identity of user in JWT format ie. who this user is
● JWT stands for Json Web Token
● JWT format is designed to reduce message size
Format :
base64UrlEncode(header_in_json_format) . base64UrlEncode(claim_in_json_format) . base64UrlEncode(signature)
Example:eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6Ik4wSXdNa1UyUWtSQk5rWkNNRFF3UWtOQ05qQkJNVFZFT0RZM1JqSkdOalUxTWpNMk1qQXhRdyJ9
.eyJpZHBfaWQiOiJhdXRoMCIsImlzcyI6Imh0dHBzOi8vc3NvLmludC5hY2NvdW50cy5kb3dqb25lcy5jb20vIiwic3ViIjoiYXV0aDB8NDE2MmI0NjgtNjYzOC0zMDc4LWI5NW
EtMTY5MDI1MmVlM2NkIiwiYXVkIjoiMkhuYWNkY0U1U3g2a0k0TEhiTWtROWlVNzROVkRYVUwiLCJleHAiOjE0OTEwMjg4NjksImlhdCI6MTQ5MDk5Mjg2OX0.i05sBSb
M6LjW0q7tHuStkeKcMRRUgqu7UAlgJCWuhmb9-NAWmdmgb1Y7IKoRcNS-BtQnOWiFEQkooQGYRtyLHkHP1DFXqb066gd0hJnr5u7i1py-QrRNOgjYLaN5JZkw8Kmc
Y4CFpNqoJScQ2B7y3bCVYCVOC8pfwGeuY2THotbGBGAUXlWN3dEIVZg-m0jsBMrHcHd0w34xYULvPfrMurHk52cdJ-zkRf1Uyl1W1QrHjuJm4w4v5qc2LpYx28YWAoJ
4Bp1EHt0zlwtD-FJs8y_kjLTVm-LHrLylq87CPjccjOkxp-oLK4P9u77b9OFRspKCZF8X96XDcQVj1WaKRA
Base64 url decode Header
{"typ": "JWT",
"alg": "RS256",
"kid": "N0IwMkU2QkRBNkZCMDQwQkNCNjBBMTVEODY3RjJGNjU1MjM2MjAxQw"
}
Base64 url decode Claim
{
"iss": "https://accounts.google.com/",
"sub": "4162b468-6638-3078-b95a-1690252ee3cd", → this is UID of user
"aud": "2HnacdcE5Sx6kI4LHbMkQ9iU74NVDXUL",
"exp": 1491028869,
"iat": 1490992869
}
SSO bypass vulnerability
● Relying Party relies on subject aka “sub” and claims to know
the who the user is to create RP session.
● Service Provider uses various JWT libraries to validation JWT
and extract claims
● Attacker exploits below issues to bypass JWT validation
1) “none” algorithm in JWT header
2) weak secret key for HMAC signing i.e. HS256
“none” algorithm
Format :
base64UrlEncode(header_in_json_format) . base64UrlEncode(claim_in_json_format) . base64UrlEncode(signature)
Example:eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6Ik4wSXdNa1UyUWtSQk5rWkNNRFF3UWtOQ05qQkJNVFZFT0RZM1JqSkdOalUxTWpNMk1qQXhRdyJ9
.eyJpZHBfaWQiOiJhdXRoMCIsImlzcyI6Imh0dHBzOi8vc3NvLmludC5hY2NvdW50cy5kb3dqb25lcy5jb20vIiwic3ViIjoiYXV0aDB8NDE2MmI0NjgtNjYzOC0zMDc4LWI5NW
EtMTY5MDI1MmVlM2NkIiwiYXVkIjoiMkhuYWNkY0U1U3g2a0k0TEhiTWtROWlVNzROVkRYVUwiLCJleHAiOjE0OTEwMjg4NjksImlhdCI6MTQ5MDk5Mjg2OX0
Header
{
"typ": "JWT",
"alg": "none", → validation bypass vulnerability
"kid": "N0IwMkU2QkRBNkZCMDQwQkNCNjBBMTVEODY3RjJGNjU1MjM2MjAxQw"
}
Claim
{
"iss": "https://accounts.google.com/",
"sub": "4162b468-6638-3078-b95a-1690252ee3cd",
"aud": "2HnacdcE5Sx6kI4LHbMkQ9iU74NVDXUL",
"exp": 1491028869,
"iat": 1490992869
}
Weak HMAC secret
Format :
base64UrlEncode(header_in_json_format) . base64UrlEncode(claim_in_json_format) . base64UrlEncode(signature)
Example:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE
2MjM5MDIyfQ.IIkR15EpG7MumcC1nM5D32_QcgUrS-ZKkCUMeajsJtU
Base64 url decoded Header
{
"typ": "JWT",
"alg": "HS256"
}
Base64 url decoded Claim
{"idp_id": "auth0",
"iss": "https://sso.int.accounts.dowjones.com/",
"sub": "auth0|4162b468-6638-3078-b95a-1690252ee3cd",
"aud": "2HnacdcE5Sx6kI4LHbMkQ9iU74NVDXUL",
"exp": 1491028869,
"iat": 1490992869
}
Signature
IIkR15EpG7MumcC1nM5D32_QcgUrS-ZKkCUMeajsJtU
Vulnerability
Signature part IIkR15EpG7MumcC1nM5D32_QcgUrS-ZKkCUMeajsJtU is signed
with “password1” shared key.
How to prevent exploitation
● Avoid JWT validation libraries which supports “none” algorithm
● Use Asymmetric key signing/validation ie. RS256 and always use “kid” field to select
corresponding public key for validation
● If RP is expecting RS256 then reject any request which doesn’t have RS256 algorithm
● If RP is expecting HS256 ( OP enforcing) then client_secret must be at least 32
character long.
Affected ones
● NodeJS JWT - https://github.com/auth0/node-jsonwebtoken and https://github.com/kjur/jsjws
● Python - https://github.com/jpadilla/pyjwt/
● PHP - https://github.com/namshi/jose and https://github.com/firebase/php-jwt
Additional tips
● Apply additional validation on JWT claims
○ validate issuer represented by claim “iss” with expected IDP domain
○ validate audience represented by claim “aud” with your own client_id
○ ensure expiry represented by claim “exp” is greater than current time
○ validate nonce represented by “nonce” claim → send me email to know more about it
■ It can prevent both id_token replay and CSRF
○ Log as much as you can but strip any PII information from logs to detect id_token abuse
○ Never store id_token, treat it as mini SAML, create your own RP session (encrypted) to retain userInfo.
● Apply additional validations on SAML attributes after retrieval
○ validate issuer represented by “Issuer” with expected IDP entityID
○ Validate audience represented by “Audience” with your own SP entityID
○ Verify “InResponseTo” in SAML response which must be same as “ID” sent in SAML Request
○ Always implement SP Initiated flow to prevent CSRF using “ID” and “InResponseTo” pair, this will
prevent SAML response replay.

Mais conteúdo relacionado

Mais procurados

API Testing Using REST Assured with TestNG
API Testing Using REST Assured with TestNGAPI Testing Using REST Assured with TestNG
API Testing Using REST Assured with TestNGSiddharth Sharma
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJSDavid Parsons
 
Spring boot Introduction
Spring boot IntroductionSpring boot Introduction
Spring boot IntroductionJeevesh Pandey
 
XSS Magic tricks
XSS Magic tricksXSS Magic tricks
XSS Magic tricksGarethHeyes
 
Introduction to ASP.NET Core
Introduction to ASP.NET CoreIntroduction to ASP.NET Core
Introduction to ASP.NET CoreAvanade Nederland
 
Introducing Swagger
Introducing SwaggerIntroducing Swagger
Introducing SwaggerTony Tam
 
Spring Framework - AOP
Spring Framework - AOPSpring Framework - AOP
Spring Framework - AOPDzmitry Naskou
 
Web Application Vulnerabilities
Web Application VulnerabilitiesWeb Application Vulnerabilities
Web Application VulnerabilitiesPreetish Panda
 
Android Application Penetration Testing - Mohammed Adam
Android Application Penetration Testing - Mohammed AdamAndroid Application Penetration Testing - Mohammed Adam
Android Application Penetration Testing - Mohammed AdamMohammed Adam
 
Spring Boot Interview Questions | Edureka
Spring Boot Interview Questions | EdurekaSpring Boot Interview Questions | Edureka
Spring Boot Interview Questions | EdurekaEdureka!
 
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016Frans Rosén
 
Understanding Cross-site Request Forgery
Understanding Cross-site Request ForgeryUnderstanding Cross-site Request Forgery
Understanding Cross-site Request ForgeryDaniel Miessler
 
Intro to Web Application Security
Intro to Web Application SecurityIntro to Web Application Security
Intro to Web Application SecurityRob Ragan
 

Mais procurados (20)

Introduction to Angularjs
Introduction to AngularjsIntroduction to Angularjs
Introduction to Angularjs
 
API Testing Using REST Assured with TestNG
API Testing Using REST Assured with TestNGAPI Testing Using REST Assured with TestNG
API Testing Using REST Assured with TestNG
 
Secure Code Review 101
Secure Code Review 101Secure Code Review 101
Secure Code Review 101
 
Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring Boot
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
Spring boot Introduction
Spring boot IntroductionSpring boot Introduction
Spring boot Introduction
 
Express JS
Express JSExpress JS
Express JS
 
XSS Magic tricks
XSS Magic tricksXSS Magic tricks
XSS Magic tricks
 
Introduction to ASP.NET Core
Introduction to ASP.NET CoreIntroduction to ASP.NET Core
Introduction to ASP.NET Core
 
Introducing Swagger
Introducing SwaggerIntroducing Swagger
Introducing Swagger
 
Spring Framework - AOP
Spring Framework - AOPSpring Framework - AOP
Spring Framework - AOP
 
Web Application Vulnerabilities
Web Application VulnerabilitiesWeb Application Vulnerabilities
Web Application Vulnerabilities
 
Android Application Penetration Testing - Mohammed Adam
Android Application Penetration Testing - Mohammed AdamAndroid Application Penetration Testing - Mohammed Adam
Android Application Penetration Testing - Mohammed Adam
 
Api security-testing
Api security-testingApi security-testing
Api security-testing
 
Spring Boot Interview Questions | Edureka
Spring Boot Interview Questions | EdurekaSpring Boot Interview Questions | Edureka
Spring Boot Interview Questions | Edureka
 
Api Testing
Api TestingApi Testing
Api Testing
 
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
 
Understanding Cross-site Request Forgery
Understanding Cross-site Request ForgeryUnderstanding Cross-site Request Forgery
Understanding Cross-site Request Forgery
 
Intro to Web Application Security
Intro to Web Application SecurityIntro to Web Application Security
Intro to Web Application Security
 
Selenium Demo
Selenium DemoSelenium Demo
Selenium Demo
 

Semelhante a Saml authentication bypass

[OPD 2019] Threat modeling at scale
[OPD 2019] Threat modeling at scale[OPD 2019] Threat modeling at scale
[OPD 2019] Threat modeling at scaleOWASP
 
How to break SAML if I have paws?
How to break SAML if I have paws?How to break SAML if I have paws?
How to break SAML if I have paws?GreenD0g
 
AAD B2C custom policies
AAD B2C custom policiesAAD B2C custom policies
AAD B2C custom policiesRory Braybrook
 
Alfresco: Implementing secure single sign on (SSO) with OpenSAML
Alfresco: Implementing secure single sign on (SSO) with OpenSAMLAlfresco: Implementing secure single sign on (SSO) with OpenSAML
Alfresco: Implementing secure single sign on (SSO) with OpenSAMLJ V
 
Top Ten Tips For Tenacious Defense In Asp.Net
Top Ten Tips For Tenacious Defense In Asp.NetTop Ten Tips For Tenacious Defense In Asp.Net
Top Ten Tips For Tenacious Defense In Asp.Netalsmola
 
Solving Single-Sign-On
Solving Single-Sign-OnSolving Single-Sign-On
Solving Single-Sign-OnAaron King
 
Serverless Design Patterns (London Dev Community)
Serverless Design Patterns (London Dev Community)Serverless Design Patterns (London Dev Community)
Serverless Design Patterns (London Dev Community)Yan Cui
 
Single Sign-On security issue in Cloud Computing
Single Sign-On security issue in Cloud ComputingSingle Sign-On security issue in Cloud Computing
Single Sign-On security issue in Cloud ComputingRahul Roshan
 
Introduction to SAML 2.0
Introduction to SAML 2.0Introduction to SAML 2.0
Introduction to SAML 2.0Mika Koivisto
 
Optimize Your SaaS Offering with Serverless Microservices (GPSTEC405) - AWS r...
Optimize Your SaaS Offering with Serverless Microservices (GPSTEC405) - AWS r...Optimize Your SaaS Offering with Serverless Microservices (GPSTEC405) - AWS r...
Optimize Your SaaS Offering with Serverless Microservices (GPSTEC405) - AWS r...Amazon Web Services
 
Php & Web Security - PHPXperts 2009
Php & Web Security - PHPXperts 2009Php & Web Security - PHPXperts 2009
Php & Web Security - PHPXperts 2009mirahman
 
Ruby Security
Ruby SecurityRuby Security
Ruby SecuritySHC
 
Web security presentation
Web security presentationWeb security presentation
Web security presentationJohn Staveley
 
Web security leeds sharp dot netnotts
Web security leeds sharp dot netnottsWeb security leeds sharp dot netnotts
Web security leeds sharp dot netnottsJohn Staveley
 
Complex architectures for authentication and authorization on AWS
Complex architectures for authentication and authorization on AWSComplex architectures for authentication and authorization on AWS
Complex architectures for authentication and authorization on AWSBoyan Dimitrov
 

Semelhante a Saml authentication bypass (20)

IdP, SAML, OAuth
IdP, SAML, OAuthIdP, SAML, OAuth
IdP, SAML, OAuth
 
[OPD 2019] Threat modeling at scale
[OPD 2019] Threat modeling at scale[OPD 2019] Threat modeling at scale
[OPD 2019] Threat modeling at scale
 
How to break SAML if I have paws?
How to break SAML if I have paws?How to break SAML if I have paws?
How to break SAML if I have paws?
 
AAD B2C custom policies
AAD B2C custom policiesAAD B2C custom policies
AAD B2C custom policies
 
Alfresco: Implementing secure single sign on (SSO) with OpenSAML
Alfresco: Implementing secure single sign on (SSO) with OpenSAMLAlfresco: Implementing secure single sign on (SSO) with OpenSAML
Alfresco: Implementing secure single sign on (SSO) with OpenSAML
 
Top Ten Tips For Tenacious Defense In Asp.Net
Top Ten Tips For Tenacious Defense In Asp.NetTop Ten Tips For Tenacious Defense In Asp.Net
Top Ten Tips For Tenacious Defense In Asp.Net
 
DIWD Concordia
DIWD ConcordiaDIWD Concordia
DIWD Concordia
 
Sso every where
Sso every whereSso every where
Sso every where
 
Solving Single-Sign-On
Solving Single-Sign-OnSolving Single-Sign-On
Solving Single-Sign-On
 
Serverless Design Patterns (London Dev Community)
Serverless Design Patterns (London Dev Community)Serverless Design Patterns (London Dev Community)
Serverless Design Patterns (London Dev Community)
 
Single Sign-On security issue in Cloud Computing
Single Sign-On security issue in Cloud ComputingSingle Sign-On security issue in Cloud Computing
Single Sign-On security issue in Cloud Computing
 
Introduction to SAML 2.0
Introduction to SAML 2.0Introduction to SAML 2.0
Introduction to SAML 2.0
 
Optimize Your SaaS Offering with Serverless Microservices (GPSTEC405) - AWS r...
Optimize Your SaaS Offering with Serverless Microservices (GPSTEC405) - AWS r...Optimize Your SaaS Offering with Serverless Microservices (GPSTEC405) - AWS r...
Optimize Your SaaS Offering with Serverless Microservices (GPSTEC405) - AWS r...
 
Single sign on using SAML
Single sign on using SAML Single sign on using SAML
Single sign on using SAML
 
Esquema de pasos de ejecución IdM
Esquema de pasos de ejecución IdMEsquema de pasos de ejecución IdM
Esquema de pasos de ejecución IdM
 
Php & Web Security - PHPXperts 2009
Php & Web Security - PHPXperts 2009Php & Web Security - PHPXperts 2009
Php & Web Security - PHPXperts 2009
 
Ruby Security
Ruby SecurityRuby Security
Ruby Security
 
Web security presentation
Web security presentationWeb security presentation
Web security presentation
 
Web security leeds sharp dot netnotts
Web security leeds sharp dot netnottsWeb security leeds sharp dot netnotts
Web security leeds sharp dot netnotts
 
Complex architectures for authentication and authorization on AWS
Complex architectures for authentication and authorization on AWSComplex architectures for authentication and authorization on AWS
Complex architectures for authentication and authorization on AWS
 

Último

Theory for How to calculation capacitor bank
Theory for How to calculation capacitor bankTheory for How to calculation capacitor bank
Theory for How to calculation capacitor banktawat puangthong
 
Intelligent Agents, A discovery on How A Rational Agent Acts
Intelligent Agents, A discovery on How A Rational Agent ActsIntelligent Agents, A discovery on How A Rational Agent Acts
Intelligent Agents, A discovery on How A Rational Agent ActsSheetal Jain
 
ChatGPT Prompt Engineering for project managers.pdf
ChatGPT Prompt Engineering for project managers.pdfChatGPT Prompt Engineering for project managers.pdf
ChatGPT Prompt Engineering for project managers.pdfqasastareekh
 
E-Commerce Shopping using MERN Stack where different modules are present
E-Commerce Shopping using MERN Stack where different modules are presentE-Commerce Shopping using MERN Stack where different modules are present
E-Commerce Shopping using MERN Stack where different modules are presentjatinraor66
 
"United Nations Park" Site Visit Report.
"United Nations Park" Site  Visit Report."United Nations Park" Site  Visit Report.
"United Nations Park" Site Visit Report.MdManikurRahman
 
solid state electronics ktu module 5 slides
solid state electronics ktu module 5 slidessolid state electronics ktu module 5 slides
solid state electronics ktu module 5 slidesARUN AV
 
Seismic Hazard Assessment Software in Python by Prof. Dr. Costas Sachpazis
Seismic Hazard Assessment Software in Python by Prof. Dr. Costas SachpazisSeismic Hazard Assessment Software in Python by Prof. Dr. Costas Sachpazis
Seismic Hazard Assessment Software in Python by Prof. Dr. Costas SachpazisDr.Costas Sachpazis
 
Supermarket billing system project report..pdf
Supermarket billing system project report..pdfSupermarket billing system project report..pdf
Supermarket billing system project report..pdfKamal Acharya
 
Activity Planning: Objectives, Project Schedule, Network Planning Model. Time...
Activity Planning: Objectives, Project Schedule, Network Planning Model. Time...Activity Planning: Objectives, Project Schedule, Network Planning Model. Time...
Activity Planning: Objectives, Project Schedule, Network Planning Model. Time...Lovely Professional University
 
Artificial Intelligence Bayesian Reasoning
Artificial Intelligence Bayesian ReasoningArtificial Intelligence Bayesian Reasoning
Artificial Intelligence Bayesian Reasoninghotman30312
 
Object Oriented Programming OOP Lab Manual.docx
Object Oriented Programming OOP Lab Manual.docxObject Oriented Programming OOP Lab Manual.docx
Object Oriented Programming OOP Lab Manual.docxRashidFaridChishti
 
Filters for Electromagnetic Compatibility Applications
Filters for Electromagnetic Compatibility ApplicationsFilters for Electromagnetic Compatibility Applications
Filters for Electromagnetic Compatibility ApplicationsMathias Magdowski
 
Low rpm Generator for efficient energy harnessing from a two stage wind turbine
Low rpm Generator for efficient energy harnessing from a two stage wind turbineLow rpm Generator for efficient energy harnessing from a two stage wind turbine
Low rpm Generator for efficient energy harnessing from a two stage wind turbineAftabkhan575376
 
ROAD CONSTRUCTION PRESENTATION.PPTX.pptx
ROAD CONSTRUCTION PRESENTATION.PPTX.pptxROAD CONSTRUCTION PRESENTATION.PPTX.pptx
ROAD CONSTRUCTION PRESENTATION.PPTX.pptxGagandeepKaur617299
 
School management system project report.pdf
School management system project report.pdfSchool management system project report.pdf
School management system project report.pdfKamal Acharya
 
Furniture showroom management system project.pdf
Furniture showroom management system project.pdfFurniture showroom management system project.pdf
Furniture showroom management system project.pdfKamal Acharya
 
Software Engineering - Modelling Concepts + Class Modelling + Building the An...
Software Engineering - Modelling Concepts + Class Modelling + Building the An...Software Engineering - Modelling Concepts + Class Modelling + Building the An...
Software Engineering - Modelling Concepts + Class Modelling + Building the An...Prakhyath Rai
 
2024 DevOps Pro Europe - Growing at the edge
2024 DevOps Pro Europe - Growing at the edge2024 DevOps Pro Europe - Growing at the edge
2024 DevOps Pro Europe - Growing at the edgePaco Orozco
 
KIT-601 Lecture Notes-UNIT-5.pdf Frame Works and Visualization
KIT-601 Lecture Notes-UNIT-5.pdf Frame Works and VisualizationKIT-601 Lecture Notes-UNIT-5.pdf Frame Works and Visualization
KIT-601 Lecture Notes-UNIT-5.pdf Frame Works and VisualizationDr. Radhey Shyam
 
ANSI(ST)-III_Manufacturing-I_05052020.pdf
ANSI(ST)-III_Manufacturing-I_05052020.pdfANSI(ST)-III_Manufacturing-I_05052020.pdf
ANSI(ST)-III_Manufacturing-I_05052020.pdfBertinKamsipa1
 

Último (20)

Theory for How to calculation capacitor bank
Theory for How to calculation capacitor bankTheory for How to calculation capacitor bank
Theory for How to calculation capacitor bank
 
Intelligent Agents, A discovery on How A Rational Agent Acts
Intelligent Agents, A discovery on How A Rational Agent ActsIntelligent Agents, A discovery on How A Rational Agent Acts
Intelligent Agents, A discovery on How A Rational Agent Acts
 
ChatGPT Prompt Engineering for project managers.pdf
ChatGPT Prompt Engineering for project managers.pdfChatGPT Prompt Engineering for project managers.pdf
ChatGPT Prompt Engineering for project managers.pdf
 
E-Commerce Shopping using MERN Stack where different modules are present
E-Commerce Shopping using MERN Stack where different modules are presentE-Commerce Shopping using MERN Stack where different modules are present
E-Commerce Shopping using MERN Stack where different modules are present
 
"United Nations Park" Site Visit Report.
"United Nations Park" Site  Visit Report."United Nations Park" Site  Visit Report.
"United Nations Park" Site Visit Report.
 
solid state electronics ktu module 5 slides
solid state electronics ktu module 5 slidessolid state electronics ktu module 5 slides
solid state electronics ktu module 5 slides
 
Seismic Hazard Assessment Software in Python by Prof. Dr. Costas Sachpazis
Seismic Hazard Assessment Software in Python by Prof. Dr. Costas SachpazisSeismic Hazard Assessment Software in Python by Prof. Dr. Costas Sachpazis
Seismic Hazard Assessment Software in Python by Prof. Dr. Costas Sachpazis
 
Supermarket billing system project report..pdf
Supermarket billing system project report..pdfSupermarket billing system project report..pdf
Supermarket billing system project report..pdf
 
Activity Planning: Objectives, Project Schedule, Network Planning Model. Time...
Activity Planning: Objectives, Project Schedule, Network Planning Model. Time...Activity Planning: Objectives, Project Schedule, Network Planning Model. Time...
Activity Planning: Objectives, Project Schedule, Network Planning Model. Time...
 
Artificial Intelligence Bayesian Reasoning
Artificial Intelligence Bayesian ReasoningArtificial Intelligence Bayesian Reasoning
Artificial Intelligence Bayesian Reasoning
 
Object Oriented Programming OOP Lab Manual.docx
Object Oriented Programming OOP Lab Manual.docxObject Oriented Programming OOP Lab Manual.docx
Object Oriented Programming OOP Lab Manual.docx
 
Filters for Electromagnetic Compatibility Applications
Filters for Electromagnetic Compatibility ApplicationsFilters for Electromagnetic Compatibility Applications
Filters for Electromagnetic Compatibility Applications
 
Low rpm Generator for efficient energy harnessing from a two stage wind turbine
Low rpm Generator for efficient energy harnessing from a two stage wind turbineLow rpm Generator for efficient energy harnessing from a two stage wind turbine
Low rpm Generator for efficient energy harnessing from a two stage wind turbine
 
ROAD CONSTRUCTION PRESENTATION.PPTX.pptx
ROAD CONSTRUCTION PRESENTATION.PPTX.pptxROAD CONSTRUCTION PRESENTATION.PPTX.pptx
ROAD CONSTRUCTION PRESENTATION.PPTX.pptx
 
School management system project report.pdf
School management system project report.pdfSchool management system project report.pdf
School management system project report.pdf
 
Furniture showroom management system project.pdf
Furniture showroom management system project.pdfFurniture showroom management system project.pdf
Furniture showroom management system project.pdf
 
Software Engineering - Modelling Concepts + Class Modelling + Building the An...
Software Engineering - Modelling Concepts + Class Modelling + Building the An...Software Engineering - Modelling Concepts + Class Modelling + Building the An...
Software Engineering - Modelling Concepts + Class Modelling + Building the An...
 
2024 DevOps Pro Europe - Growing at the edge
2024 DevOps Pro Europe - Growing at the edge2024 DevOps Pro Europe - Growing at the edge
2024 DevOps Pro Europe - Growing at the edge
 
KIT-601 Lecture Notes-UNIT-5.pdf Frame Works and Visualization
KIT-601 Lecture Notes-UNIT-5.pdf Frame Works and VisualizationKIT-601 Lecture Notes-UNIT-5.pdf Frame Works and Visualization
KIT-601 Lecture Notes-UNIT-5.pdf Frame Works and Visualization
 
ANSI(ST)-III_Manufacturing-I_05052020.pdf
ANSI(ST)-III_Manufacturing-I_05052020.pdfANSI(ST)-III_Manufacturing-I_05052020.pdf
ANSI(ST)-III_Manufacturing-I_05052020.pdf
 

Saml authentication bypass

  • 1. SSO Vulnerabilities Tarachand Verma Identity Access And Management Lead
  • 2. What is Single Sign On App1 App3 App2 Identity Provider (IdP) login login login Responsibility - Presents login page - Verifies credentials - Creates and maintain user sso session - Returns identity to app securely - Skip login page if user already has session User credentials Database Most popular SSO protocols - SAML - OpenID-Connect send identity to app securely Internal DB call
  • 3. SAML SSO Service Provider (SP) Identity Provider (IdP)login Responsibility - Presents login page - Verifies credentials - Creates and maintain user session - Returns identity to app using signed/encrypted SAML response - Skip login page if user already has session on subsequent login requests User credentials Database Examples www.example.com(SP) → google.com( IdP) SAML2 SP_acs?SAMLResponse=signed_or_encrypted(identity)
  • 4. SAML Response (abbreviated) <saml:Assertion ID="123"> <saml:Issuer>google.com</saml:Issuer> <saml:Subject> <saml:NameID>john.doe@example.com</saml:NameID> </saml:Subject> <saml:Conditions NotBefore="2018-08-20T00:00:00Z" NotOnOrAfter="2018-08-21T00:00:00Z"> <saml:AudienceRestriction> <saml:Audience>www.example.com</saml:Audience> </saml:AudienceRestriction> </saml:Conditions> </saml:Assertion>
  • 5. SAML SSO bypass vulnerability ● Service Provider relies on Subject/NameID and Assertions to know the who the user is to create SP session. ● Service Provider uses various SAML libraries to parse SAML response ( XML Formatted ) ● Attacker exploits two issues to manipulate parsed data 1) XML parsing issue 2) Cryptographic signing issue
  • 6. Issue #1 - XML Parsing Issue XML <saml:NameID>not-a-cto@example.com</saml:NameID> Parsed NameID |_ Text: not-a-cto@example.com XML <saml:NameID>not-a-<!-- this is a comment -->cto@example.com</saml:NameID> Parsed NameID |_ Text: not-a- |_ Comment: this is a comment |_ Text: cto@example.com → here is the vulnerability
  • 7. Issue #2 - Cryptographic signing Both XML will have same cryptographic signature <p> hello </p> And <p>hello</p> Reason: because XML doesn’t care about whitespace. When the XML document is analyzed before a signature is created, space is removed. Its called canonicalization. Most canonicalization algorithms also don’t care about comments → vulnerability That means both will have same signature. <saml:NameID>not-a-<!-- this is a comment -->cto@example.com</saml:NameID> And <saml:NameID>not-a-cto@example.com</saml:NameID>
  • 8. SAML Response with Canonicalization algo <SAMLResponse> <Issuer>https://google.com/</Issuer> <Assertion ID="_id1234"> <Subject> <NameID>non-a-cto@example.com</NameID> </Subject> </Assertion> <Signature> <SignedInfo> <CanonicalizationMethod Algorithm="xml-c14n11"/> <Reference URI="#_id1234"/> </SignedInfo> <SignatureValue> some base64 data that represents the signature of the assertion </SignatureValue> </Signature> </SAMLResponse>
  • 9. How attacker exploits Precondition a) Attacker owns his own account at Identity Provider AND b) Knows what’s canonicalization Steps 1) Attacker creates/has an account with emailAddress - not-a-cto@example.com 2) Attacker logs in the IdP i.e. Example.com and updates his own emailAddress to not-a-<!-- this is a comment -->cto@example.com 3) Attacker logs out and logs back in which generates SAML response with comments to exploit XML parsing vulnerability OR 1) Attacker creates/has an account with emailAddress - not-a-cto@example.com 2) Attacker logs in the IdP and grabs SAML response and updates assertion to not-a-<!-- this is a comment -->cto@example.com 4) Replays SAML response to exploit weak XML canonicalization vulnerability
  • 10. How to prevent exploitation ● Avoid SAML and use more modern OpenID-Connect which doesn’t use XML ● Check your SAML library and dependent XML parsing and signature verification libraries and check for vulnerabilities. ● As an IdP, purge comments while creating XML documents ● As an SP, reject any SAML attribute if XML attribute node contains more than one child. ● Use canonicalization algorithm which doesn’t remove comments while generating signature - http://www.w3.org/2001/10/xml-exc-c14n#WithComments Affected ones ● OneLogin’s python-saml, ● OneLogin’s ruby-saml, ● Clever’s saml2, ● omniauth-saml, and ● Shibboleth’s openSAML C++
  • 11. OpenID-Connect App (RP aka Relying Party) OpenID-Connect Provider (OP) login Responsibility - Presents login page - Verifies credentials - Creates and maintain user session - Returns identity to app using signed id_token response(JWT formatted) - Skip login page if user already has session on subsequent login requests User credentials Database Examples www.example.com(RP) → accounts.google.com( OP) OpenID RP_callback?id_token=signed(identity)
  • 12. id_token (JWT formatted) ● id_token represents identity of user in JWT format ie. who this user is ● JWT stands for Json Web Token ● JWT format is designed to reduce message size Format : base64UrlEncode(header_in_json_format) . base64UrlEncode(claim_in_json_format) . base64UrlEncode(signature) Example:eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6Ik4wSXdNa1UyUWtSQk5rWkNNRFF3UWtOQ05qQkJNVFZFT0RZM1JqSkdOalUxTWpNMk1qQXhRdyJ9 .eyJpZHBfaWQiOiJhdXRoMCIsImlzcyI6Imh0dHBzOi8vc3NvLmludC5hY2NvdW50cy5kb3dqb25lcy5jb20vIiwic3ViIjoiYXV0aDB8NDE2MmI0NjgtNjYzOC0zMDc4LWI5NW EtMTY5MDI1MmVlM2NkIiwiYXVkIjoiMkhuYWNkY0U1U3g2a0k0TEhiTWtROWlVNzROVkRYVUwiLCJleHAiOjE0OTEwMjg4NjksImlhdCI6MTQ5MDk5Mjg2OX0.i05sBSb M6LjW0q7tHuStkeKcMRRUgqu7UAlgJCWuhmb9-NAWmdmgb1Y7IKoRcNS-BtQnOWiFEQkooQGYRtyLHkHP1DFXqb066gd0hJnr5u7i1py-QrRNOgjYLaN5JZkw8Kmc Y4CFpNqoJScQ2B7y3bCVYCVOC8pfwGeuY2THotbGBGAUXlWN3dEIVZg-m0jsBMrHcHd0w34xYULvPfrMurHk52cdJ-zkRf1Uyl1W1QrHjuJm4w4v5qc2LpYx28YWAoJ 4Bp1EHt0zlwtD-FJs8y_kjLTVm-LHrLylq87CPjccjOkxp-oLK4P9u77b9OFRspKCZF8X96XDcQVj1WaKRA Base64 url decode Header {"typ": "JWT", "alg": "RS256", "kid": "N0IwMkU2QkRBNkZCMDQwQkNCNjBBMTVEODY3RjJGNjU1MjM2MjAxQw" } Base64 url decode Claim { "iss": "https://accounts.google.com/", "sub": "4162b468-6638-3078-b95a-1690252ee3cd", → this is UID of user "aud": "2HnacdcE5Sx6kI4LHbMkQ9iU74NVDXUL", "exp": 1491028869, "iat": 1490992869 }
  • 13. SSO bypass vulnerability ● Relying Party relies on subject aka “sub” and claims to know the who the user is to create RP session. ● Service Provider uses various JWT libraries to validation JWT and extract claims ● Attacker exploits below issues to bypass JWT validation 1) “none” algorithm in JWT header 2) weak secret key for HMAC signing i.e. HS256
  • 14. “none” algorithm Format : base64UrlEncode(header_in_json_format) . base64UrlEncode(claim_in_json_format) . base64UrlEncode(signature) Example:eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6Ik4wSXdNa1UyUWtSQk5rWkNNRFF3UWtOQ05qQkJNVFZFT0RZM1JqSkdOalUxTWpNMk1qQXhRdyJ9 .eyJpZHBfaWQiOiJhdXRoMCIsImlzcyI6Imh0dHBzOi8vc3NvLmludC5hY2NvdW50cy5kb3dqb25lcy5jb20vIiwic3ViIjoiYXV0aDB8NDE2MmI0NjgtNjYzOC0zMDc4LWI5NW EtMTY5MDI1MmVlM2NkIiwiYXVkIjoiMkhuYWNkY0U1U3g2a0k0TEhiTWtROWlVNzROVkRYVUwiLCJleHAiOjE0OTEwMjg4NjksImlhdCI6MTQ5MDk5Mjg2OX0 Header { "typ": "JWT", "alg": "none", → validation bypass vulnerability "kid": "N0IwMkU2QkRBNkZCMDQwQkNCNjBBMTVEODY3RjJGNjU1MjM2MjAxQw" } Claim { "iss": "https://accounts.google.com/", "sub": "4162b468-6638-3078-b95a-1690252ee3cd", "aud": "2HnacdcE5Sx6kI4LHbMkQ9iU74NVDXUL", "exp": 1491028869, "iat": 1490992869 }
  • 15. Weak HMAC secret Format : base64UrlEncode(header_in_json_format) . base64UrlEncode(claim_in_json_format) . base64UrlEncode(signature) Example:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE 2MjM5MDIyfQ.IIkR15EpG7MumcC1nM5D32_QcgUrS-ZKkCUMeajsJtU Base64 url decoded Header { "typ": "JWT", "alg": "HS256" } Base64 url decoded Claim {"idp_id": "auth0", "iss": "https://sso.int.accounts.dowjones.com/", "sub": "auth0|4162b468-6638-3078-b95a-1690252ee3cd", "aud": "2HnacdcE5Sx6kI4LHbMkQ9iU74NVDXUL", "exp": 1491028869, "iat": 1490992869 } Signature IIkR15EpG7MumcC1nM5D32_QcgUrS-ZKkCUMeajsJtU Vulnerability Signature part IIkR15EpG7MumcC1nM5D32_QcgUrS-ZKkCUMeajsJtU is signed with “password1” shared key.
  • 16. How to prevent exploitation ● Avoid JWT validation libraries which supports “none” algorithm ● Use Asymmetric key signing/validation ie. RS256 and always use “kid” field to select corresponding public key for validation ● If RP is expecting RS256 then reject any request which doesn’t have RS256 algorithm ● If RP is expecting HS256 ( OP enforcing) then client_secret must be at least 32 character long. Affected ones ● NodeJS JWT - https://github.com/auth0/node-jsonwebtoken and https://github.com/kjur/jsjws ● Python - https://github.com/jpadilla/pyjwt/ ● PHP - https://github.com/namshi/jose and https://github.com/firebase/php-jwt
  • 17. Additional tips ● Apply additional validation on JWT claims ○ validate issuer represented by claim “iss” with expected IDP domain ○ validate audience represented by claim “aud” with your own client_id ○ ensure expiry represented by claim “exp” is greater than current time ○ validate nonce represented by “nonce” claim → send me email to know more about it ■ It can prevent both id_token replay and CSRF ○ Log as much as you can but strip any PII information from logs to detect id_token abuse ○ Never store id_token, treat it as mini SAML, create your own RP session (encrypted) to retain userInfo. ● Apply additional validations on SAML attributes after retrieval ○ validate issuer represented by “Issuer” with expected IDP entityID ○ Validate audience represented by “Audience” with your own SP entityID ○ Verify “InResponseTo” in SAML response which must be same as “ID” sent in SAML Request ○ Always implement SP Initiated flow to prevent CSRF using “ID” and “InResponseTo” pair, this will prevent SAML response replay.