SlideShare uma empresa Scribd logo
1 de 35
Baixar para ler offline
Abusing
Twitter API
Nicolas Seriot




                 Application Security Forum - 2012
                                    Western Switzerland

                 7-8 novembre 2012
                 Y-Parc / Yverdon-les-Bains
                 https://www.appsec-forum.ch
Bio

• Cocoa developer
• HES Software Engineer
• MAS Eco. Crime Investigation
• Twitter user since July, 2008
• Father of a newborn
Agenda

1. Twitter
2. OAuth
3. Ripping Consumer Tokens
4. iOS / OS X + STTwitter
5. Discussion
Tweets/day
      now $8 billion valuation,                             340M
      top-10 most visited websites
                                                         140M
                   5000        1M         22 50 65


                          verified             promo.      Dick promo. no
                         accounts trending    tweets     Costolo tweets more
Twitter                (celebrities) topics    web        CEO    mobile RSS
launch

 2006         2007        2008       2009       2010         2011        2012
                                          Tweetie TweetDeck          stricter ToS,
                                           buyout buyout          display guidelines
                                                       last OS X client update
                                                                                  v. 1.1
API




                                                           OAuth API v. 1.0
                 HTTP Basic Authentication
March 2013: Maximum Evilness




       “We’re trying to limit certain use cases
       that occupy the upper-right quadrant.”
 https://dev.twitter.com/blog/changes-coming-to-twitter-api
•   The author’s name and @username must be displayed to the right of the avatar.

•   Reply, Retweet and Favorite Tweet actions must always be available.

•   No other 3rd party actions similar to Follow, Reply, Retweet may be attached to a Tweet.

•   The Twitter logo or Follow button for the Tweet author must always be displayed.

•   The Tweet timestamp must always be linked to the Tweet permalink.

•   A timeline must not be rendered with non-Twitter content. e.g. from other networks.



        https://dev.twitter.com/terms/display-requirements
• Max. 100’000 users per Twitter client app.
        • “Twitter discourages development in this area”
            https://dev.twitter.com/terms/api-terms
"Developers ask us if they should build
  client apps that mimic or reproduce
the mainstream Twitter consumer client
     experience. The answer is no."

     "We need to move to a less
 fragmented world, where every user
  can experience Twitter in a
        consistent way."

https://groups.google.com/forum/#!
   msg/twitter-development-talk/
  yCzVnHqHIWo/sC34r_ZyMLYJ
Developers ♥ Stupid Rules!



"Twitter obviously wants to make money by advertising in the stream.
This will be impossible if all of the mechanisms aren't implemented to spec
   within a client. They need full control of how the information is
 presented, and do not have the bandwidth to micromanage ads with third
               parties to prevent fraud, poor presentation, etc,"

http://www.theverge.com/2012/7/9/3135406/twitter-api-open-closed-
                     facebook-walled-garden
Breaking the Rules

• OAuth authentication for every API request
• "We reserve the right to revoke your app"
  https://dev.twitter.com/terms/api-terms
• Can a rogue client spoof the identity of a
  regular client and use the API as it wants?
Agenda

1. Twitter
2. OAuth
3. Ripping Consumer Tokens
4. iOS / OS X + STTwitter
5. Discussion
http://hueniverse.com/2007/09/oauth-isnt-always-the-solution/
@nst021            bitly                    Twitter
    “Use my account”
                            request_token




                                                      OAuth / Web
                               authorize



                           access_token



                            home_timeline        green coin is
                                                 for bitly and
                                                   @nst021
@nst021 / iOS             Twitter




                                    OAuth / Desktop
          request_token




             authorize



         access_token



          home_timeline        green coin is
                               for bitly and
                                 @nst021
@nst021 / iOS             Twitter




                                                 Authentication
request_secret             request_token




                                                 PIN: 3 phases
request_key

consumer_secret
consumer_key                  authorize
verifier

access_secret             access_token
access_key


                           home_timeline        green coin is
                                                for bitly and
                                                  @nst021
@nst021 / iOS             Twitter




                                                Authentication
                                                xAuth: 1 phase
consumer_secret
consumer_key



access_secret            access_token
access_key

username
                          home_timeline        green coin is
password                                       for bitly and
                                                 @nst021
Agenda

1. Twitter
2. OAuth
3. Ripping Consumer Tokens
4. iOS / OS X + STTwitter
5. Discussion
/usr/bin/strings

$ strings /Applications/Twitter.app/ 
           Contents/MacOS/Twitter

3rJOl1ODzm9yZy63FACdg
5jPo**************************************
Test the Tokens
#!/usr/bin/env python

import tweepy

CONSUMER_KEY = '3rJOl1ODzm9yZy63FACdg'
CONSUMER_SECRET = '5jPo**************************************'

auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth_url = auth.get_authorization_url()
print "Please authorize:", auth_url

verifier = raw_input('PIN: ').strip()
auth.get_access_token(verifier)

print "ACCESS_KEY:", auth.access_token.key
print "ACCESS_SECRET:", auth.access_token.secret



                           demo
/usr/bin/gdb
$ gdb attach <PID of OS X accountsd>

(gdb) b -[OACredential consumerKey]
(gdb) finish
(gdb) po $rax
tXvOrlJDmLnTfiUqJ3Kuw

(gdb) b -[OACredential consumerSecret]
(gdb) finish
(gdb) po $rax
AWcB**************************************
/usr/bin/gdb
$ gdb attach <PID of iPhoneSimulator accountsd>

(gdb) b -[OACredential consumerKey]
(gdb) finish
(gdb) po (int*)$eax
WXZE9QillkIZpTANgLNT9g

(gdb) b -[OACredential consumerSecret]
(gdb) finish
(gdb) po (int*)$eax
Aau5**************************************



                     demo
Logging Freed Strings


$ sudo dtrace -n 'pid$target::free:entry { 
  printf("%s", arg0 != NULL ? 
               copyinstr(arg0) : 
               "<NULL>"); }' -p 10123
Objective-C Variant
@implementation NSString (XX)
+ (void)load {
     Swizzle([NSString class],
     @selector(dealloc),
     @selector(my_dealloc));
}
- (void)my_dealloc {
     NSLog(@"%@", self);
     [self my_dealloc];
}
@end

(gdb) p (char)[[NSBundle bundleWithPath:
  @"/Library/Frameworks/XX.framework"] load]
Other Techniques

• Memory dump
 $ sudo ./gcore64 -c /tmp/dump.bin 4149

 $ strings dump.bin | sort -u > /tmp/dump.txt

 # key=consumerSecret&
 $ egrep "[a-zA-Z0-9]{20}&$" /tmp/dump.txt


• Google…
Agenda

1. Twitter
2. OAuth
3. Ripping Consumer Tokens
4. iOS / OS X + STTwitter
5. Discussion
OS X Twitter Credentials




      Accounts.framework


           @nst021
           xxxxxx
can use OS X                      …or can use custom
consumer tokens…                     consumer tokens

                STTwitterAPIWrapper
            + twitterAPIWith...
            - getHomeTimeline




                                               STTwitter
            - postStatus

                STTwitterOAuthProtocol

                              STTwitterOAuth
          STOAuthOSX
                              STHTTPRequest

         Accounts.framework
          Social.framework
STTwitter




https://github.com/nst/STTwitter

demo from 55.750984, 37.617571
TwitHunter




https://github.com/nst/TwitHunter
Agenda

1. Twitter
2. OAuth
3. Ripping Consumer Tokens
4. iOS / OS X + STTwitter
5. Discussion
1. Taking OAuth from web to Desktop was a
   conceptual error. Consumer tokens simply
   just cannot be kept secret on the Desktop.
2. Twitter cannot realistically revoke keys from
   popular clients, especially from OS X / iOS.
3. xAuth brings nothing more that HTTP Digest
   Authentication, and sends password in the
   request token phase.
4. OAuth cannot reliably identify the client, and
   additionally puts the users at risk.
             OAuth Session Fixation Attack Demo
5. I have to conclude that the real grounds for
   using OAuth is neither “security” nor spam
   fighting but desire to control third-
   party client applications to please big
   media, consumers and advertisers.
6. Sadly for Twitter, ensuring that the requests
   come from a certain client application is a
   very hard problem, and I am not sure if it
   can be solved.
Recap
1. Twitter
2. OAuth
3. Ripping Consumer Tokens
4. iOS / OS X + STTwitter
5. Discussion
Twitter:
 @nst021

Web:
 http://seriot.ch/abusing_twitter_api.php

Slides:
 http://www.slideshare.net/ASF-WS/presentations

Mais conteúdo relacionado

Semelhante a Abusing Twitter API: Ripping Consumer Tokens

Using OAuth with PHP
Using OAuth with PHPUsing OAuth with PHP
Using OAuth with PHPDavid Ingram
 
OAuth for QuickBooks Online REST Services
OAuth for QuickBooks Online REST ServicesOAuth for QuickBooks Online REST Services
OAuth for QuickBooks Online REST ServicesIntuit Developer
 
Building TweetEngine
Building TweetEngineBuilding TweetEngine
Building TweetEngineikailan
 
Mz twitter-1.1-sdl
Mz twitter-1.1-sdlMz twitter-1.1-sdl
Mz twitter-1.1-sdlAngus Fox
 
APIdays Paris 2018 - Learning the OAuth Dance (Without Stepping on Anyone's T...
APIdays Paris 2018 - Learning the OAuth Dance (Without Stepping on Anyone's T...APIdays Paris 2018 - Learning the OAuth Dance (Without Stepping on Anyone's T...
APIdays Paris 2018 - Learning the OAuth Dance (Without Stepping on Anyone's T...apidays
 
Embedded Tweets, Timelines and Twitter Cards - Social Developers London 09 Ja...
Embedded Tweets, Timelines and Twitter Cards - Social Developers London 09 Ja...Embedded Tweets, Timelines and Twitter Cards - Social Developers London 09 Ja...
Embedded Tweets, Timelines and Twitter Cards - Social Developers London 09 Ja...Angus Fox
 
Electric Capital Developer Report 2022
Electric Capital Developer Report 2022Electric Capital Developer Report 2022
Electric Capital Developer Report 2022MariaShen2
 
2019 ITkonekt Stateless REST Security with MicroProfile JWT
2019 ITkonekt Stateless REST Security with MicroProfile JWT2019 ITkonekt Stateless REST Security with MicroProfile JWT
2019 ITkonekt Stateless REST Security with MicroProfile JWTJean-Louis MONTEIRO
 
I Know What Youll Do Next Summer - The Skills You Will Be Learning 
as a Domi...
I Know What Youll Do Next Summer - The Skills You Will Be Learning 
as a Domi...I Know What Youll Do Next Summer - The Skills You Will Be Learning 
as a Domi...
I Know What Youll Do Next Summer - The Skills You Will Be Learning 
as a Domi...Grégory Engels
 
B-sides Las Vegas - social network security
B-sides Las Vegas - social network securityB-sides Las Vegas - social network security
B-sides Las Vegas - social network securityDamon Cortesi
 
Ethereum Devcon1 Report (summary writing)
Ethereum Devcon1 Report (summary writing)Ethereum Devcon1 Report (summary writing)
Ethereum Devcon1 Report (summary writing)Tomoaki Sato
 
Electric Capital Crypto Dev Report · 2022
Electric Capital Crypto Dev Report · 2022Electric Capital Crypto Dev Report · 2022
Electric Capital Crypto Dev Report · 2022Maria Xinhe Shen
 
Patterns to Bring Enterprise and Social Identity to the Cloud
Patterns to Bring Enterprise and Social Identity to the Cloud Patterns to Bring Enterprise and Social Identity to the Cloud
Patterns to Bring Enterprise and Social Identity to the Cloud CA API Management
 
The Many Flavors of OAuth - Understand Everything About OAuth2
The Many Flavors of OAuth - Understand Everything About OAuth2The Many Flavors of OAuth - Understand Everything About OAuth2
The Many Flavors of OAuth - Understand Everything About OAuth2Khor SoonHin
 
HackPR at UPR in Mayaguez - September 2015
HackPR at UPR in Mayaguez - September 2015HackPR at UPR in Mayaguez - September 2015
HackPR at UPR in Mayaguez - September 2015Jonathan Bulava
 
FIWARE IoT Proposal & Community
FIWARE IoT Proposal & CommunityFIWARE IoT Proposal & Community
FIWARE IoT Proposal & CommunityFIWARE
 
BotCommons: Metadata for Bots - Devoxx 2017
BotCommons: Metadata for Bots - Devoxx 2017BotCommons: Metadata for Bots - Devoxx 2017
BotCommons: Metadata for Bots - Devoxx 2017Cisco DevNet
 
Federated Identity for IoT with OAuth2
Federated Identity for IoT with OAuth2Federated Identity for IoT with OAuth2
Federated Identity for IoT with OAuth2Paul Fremantle
 

Semelhante a Abusing Twitter API: Ripping Consumer Tokens (20)

Using OAuth with PHP
Using OAuth with PHPUsing OAuth with PHP
Using OAuth with PHP
 
OAuth for QuickBooks Online REST Services
OAuth for QuickBooks Online REST ServicesOAuth for QuickBooks Online REST Services
OAuth for QuickBooks Online REST Services
 
Building TweetEngine
Building TweetEngineBuilding TweetEngine
Building TweetEngine
 
Mz twitter-1.1-sdl
Mz twitter-1.1-sdlMz twitter-1.1-sdl
Mz twitter-1.1-sdl
 
APIdays Paris 2018 - Learning the OAuth Dance (Without Stepping on Anyone's T...
APIdays Paris 2018 - Learning the OAuth Dance (Without Stepping on Anyone's T...APIdays Paris 2018 - Learning the OAuth Dance (Without Stepping on Anyone's T...
APIdays Paris 2018 - Learning the OAuth Dance (Without Stepping on Anyone's T...
 
Embedded Tweets, Timelines and Twitter Cards - Social Developers London 09 Ja...
Embedded Tweets, Timelines and Twitter Cards - Social Developers London 09 Ja...Embedded Tweets, Timelines and Twitter Cards - Social Developers London 09 Ja...
Embedded Tweets, Timelines and Twitter Cards - Social Developers London 09 Ja...
 
Electric Capital Developer Report 2022
Electric Capital Developer Report 2022Electric Capital Developer Report 2022
Electric Capital Developer Report 2022
 
2019 ITkonekt Stateless REST Security with MicroProfile JWT
2019 ITkonekt Stateless REST Security with MicroProfile JWT2019 ITkonekt Stateless REST Security with MicroProfile JWT
2019 ITkonekt Stateless REST Security with MicroProfile JWT
 
I Know What Youll Do Next Summer - The Skills You Will Be Learning 
as a Domi...
I Know What Youll Do Next Summer - The Skills You Will Be Learning 
as a Domi...I Know What Youll Do Next Summer - The Skills You Will Be Learning 
as a Domi...
I Know What Youll Do Next Summer - The Skills You Will Be Learning 
as a Domi...
 
B-sides Las Vegas - social network security
B-sides Las Vegas - social network securityB-sides Las Vegas - social network security
B-sides Las Vegas - social network security
 
Ethereum Devcon1 Report (summary writing)
Ethereum Devcon1 Report (summary writing)Ethereum Devcon1 Report (summary writing)
Ethereum Devcon1 Report (summary writing)
 
Electric Capital Crypto Dev Report · 2022
Electric Capital Crypto Dev Report · 2022Electric Capital Crypto Dev Report · 2022
Electric Capital Crypto Dev Report · 2022
 
Crypto Dev Report · 2022
Crypto Dev Report · 2022Crypto Dev Report · 2022
Crypto Dev Report · 2022
 
Patterns to Bring Enterprise and Social Identity to the Cloud
Patterns to Bring Enterprise and Social Identity to the Cloud Patterns to Bring Enterprise and Social Identity to the Cloud
Patterns to Bring Enterprise and Social Identity to the Cloud
 
The Many Flavors of OAuth - Understand Everything About OAuth2
The Many Flavors of OAuth - Understand Everything About OAuth2The Many Flavors of OAuth - Understand Everything About OAuth2
The Many Flavors of OAuth - Understand Everything About OAuth2
 
HackPR at UPR in Mayaguez - September 2015
HackPR at UPR in Mayaguez - September 2015HackPR at UPR in Mayaguez - September 2015
HackPR at UPR in Mayaguez - September 2015
 
Some OAuth love
Some OAuth loveSome OAuth love
Some OAuth love
 
FIWARE IoT Proposal & Community
FIWARE IoT Proposal & CommunityFIWARE IoT Proposal & Community
FIWARE IoT Proposal & Community
 
BotCommons: Metadata for Bots - Devoxx 2017
BotCommons: Metadata for Bots - Devoxx 2017BotCommons: Metadata for Bots - Devoxx 2017
BotCommons: Metadata for Bots - Devoxx 2017
 
Federated Identity for IoT with OAuth2
Federated Identity for IoT with OAuth2Federated Identity for IoT with OAuth2
Federated Identity for IoT with OAuth2
 

Mais de Cyber Security Alliance

Robots are among us, but who takes responsibility?
Robots are among us, but who takes responsibility?Robots are among us, but who takes responsibility?
Robots are among us, but who takes responsibility?Cyber Security Alliance
 
iOS malware: what's the risk and how to reduce it
iOS malware: what's the risk and how to reduce itiOS malware: what's the risk and how to reduce it
iOS malware: what's the risk and how to reduce itCyber Security Alliance
 
Why huntung IoC fails at protecting against targeted attacks
Why huntung IoC fails at protecting against targeted attacksWhy huntung IoC fails at protecting against targeted attacks
Why huntung IoC fails at protecting against targeted attacksCyber Security Alliance
 
Corporations - the new victims of targeted ransomware
Corporations - the new victims of targeted ransomwareCorporations - the new victims of targeted ransomware
Corporations - the new victims of targeted ransomwareCyber Security Alliance
 
Introducing Man in the Contacts attack to trick encrypted messaging apps
Introducing Man in the Contacts attack to trick encrypted messaging appsIntroducing Man in the Contacts attack to trick encrypted messaging apps
Introducing Man in the Contacts attack to trick encrypted messaging appsCyber Security Alliance
 
Understanding the fundamentals of attacks
Understanding the fundamentals of attacksUnderstanding the fundamentals of attacks
Understanding the fundamentals of attacksCyber Security Alliance
 
Reverse engineering Swisscom's Centro Grande Modem
Reverse engineering Swisscom's Centro Grande ModemReverse engineering Swisscom's Centro Grande Modem
Reverse engineering Swisscom's Centro Grande ModemCyber Security Alliance
 
Easy public-private-keys-strong-authentication-using-u2 f
Easy public-private-keys-strong-authentication-using-u2 fEasy public-private-keys-strong-authentication-using-u2 f
Easy public-private-keys-strong-authentication-using-u2 fCyber Security Alliance
 
Create a-strong-two-factors-authentication-device-for-less-than-chf-100
Create a-strong-two-factors-authentication-device-for-less-than-chf-100Create a-strong-two-factors-authentication-device-for-less-than-chf-100
Create a-strong-two-factors-authentication-device-for-less-than-chf-100Cyber Security Alliance
 
Offline bruteforce attack on wi fi protected setup
Offline bruteforce attack on wi fi protected setupOffline bruteforce attack on wi fi protected setup
Offline bruteforce attack on wi fi protected setupCyber Security Alliance
 
App secforum2014 andrivet-cplusplus11-metaprogramming_applied_to_software_obf...
App secforum2014 andrivet-cplusplus11-metaprogramming_applied_to_software_obf...App secforum2014 andrivet-cplusplus11-metaprogramming_applied_to_software_obf...
App secforum2014 andrivet-cplusplus11-metaprogramming_applied_to_software_obf...Cyber Security Alliance
 
Warning Ahead: SecurityStorms are Brewing in Your JavaScript
Warning Ahead: SecurityStorms are Brewing in Your JavaScriptWarning Ahead: SecurityStorms are Brewing in Your JavaScript
Warning Ahead: SecurityStorms are Brewing in Your JavaScriptCyber Security Alliance
 
Killing any security product … using a Mimikatz undocumented feature
Killing any security product … using a Mimikatz undocumented featureKilling any security product … using a Mimikatz undocumented feature
Killing any security product … using a Mimikatz undocumented featureCyber Security Alliance
 

Mais de Cyber Security Alliance (20)

Bug Bounty @ Swisscom
Bug Bounty @ SwisscomBug Bounty @ Swisscom
Bug Bounty @ Swisscom
 
Robots are among us, but who takes responsibility?
Robots are among us, but who takes responsibility?Robots are among us, but who takes responsibility?
Robots are among us, but who takes responsibility?
 
iOS malware: what's the risk and how to reduce it
iOS malware: what's the risk and how to reduce itiOS malware: what's the risk and how to reduce it
iOS malware: what's the risk and how to reduce it
 
Why huntung IoC fails at protecting against targeted attacks
Why huntung IoC fails at protecting against targeted attacksWhy huntung IoC fails at protecting against targeted attacks
Why huntung IoC fails at protecting against targeted attacks
 
Corporations - the new victims of targeted ransomware
Corporations - the new victims of targeted ransomwareCorporations - the new victims of targeted ransomware
Corporations - the new victims of targeted ransomware
 
Blockchain for Beginners
Blockchain for Beginners Blockchain for Beginners
Blockchain for Beginners
 
Le pentest pour les nuls #cybsec16
Le pentest pour les nuls #cybsec16Le pentest pour les nuls #cybsec16
Le pentest pour les nuls #cybsec16
 
Introducing Man in the Contacts attack to trick encrypted messaging apps
Introducing Man in the Contacts attack to trick encrypted messaging appsIntroducing Man in the Contacts attack to trick encrypted messaging apps
Introducing Man in the Contacts attack to trick encrypted messaging apps
 
Understanding the fundamentals of attacks
Understanding the fundamentals of attacksUnderstanding the fundamentals of attacks
Understanding the fundamentals of attacks
 
Rump : iOS patch diffing
Rump : iOS patch diffingRump : iOS patch diffing
Rump : iOS patch diffing
 
An easy way into your sap systems v3.0
An easy way into your sap systems v3.0An easy way into your sap systems v3.0
An easy way into your sap systems v3.0
 
Reverse engineering Swisscom's Centro Grande Modem
Reverse engineering Swisscom's Centro Grande ModemReverse engineering Swisscom's Centro Grande Modem
Reverse engineering Swisscom's Centro Grande Modem
 
Easy public-private-keys-strong-authentication-using-u2 f
Easy public-private-keys-strong-authentication-using-u2 fEasy public-private-keys-strong-authentication-using-u2 f
Easy public-private-keys-strong-authentication-using-u2 f
 
Create a-strong-two-factors-authentication-device-for-less-than-chf-100
Create a-strong-two-factors-authentication-device-for-less-than-chf-100Create a-strong-two-factors-authentication-device-for-less-than-chf-100
Create a-strong-two-factors-authentication-device-for-less-than-chf-100
 
Offline bruteforce attack on wi fi protected setup
Offline bruteforce attack on wi fi protected setupOffline bruteforce attack on wi fi protected setup
Offline bruteforce attack on wi fi protected setup
 
App secforum2014 andrivet-cplusplus11-metaprogramming_applied_to_software_obf...
App secforum2014 andrivet-cplusplus11-metaprogramming_applied_to_software_obf...App secforum2014 andrivet-cplusplus11-metaprogramming_applied_to_software_obf...
App secforum2014 andrivet-cplusplus11-metaprogramming_applied_to_software_obf...
 
Warning Ahead: SecurityStorms are Brewing in Your JavaScript
Warning Ahead: SecurityStorms are Brewing in Your JavaScriptWarning Ahead: SecurityStorms are Brewing in Your JavaScript
Warning Ahead: SecurityStorms are Brewing in Your JavaScript
 
Killing any security product … using a Mimikatz undocumented feature
Killing any security product … using a Mimikatz undocumented featureKilling any security product … using a Mimikatz undocumented feature
Killing any security product … using a Mimikatz undocumented feature
 
Rump attaque usb_caralinda_fabrice
Rump attaque usb_caralinda_fabriceRump attaque usb_caralinda_fabrice
Rump attaque usb_caralinda_fabrice
 
Operation emmental appsec
Operation emmental appsecOperation emmental appsec
Operation emmental appsec
 

Abusing Twitter API: Ripping Consumer Tokens

  • 1. Abusing Twitter API Nicolas Seriot Application Security Forum - 2012 Western Switzerland 7-8 novembre 2012 Y-Parc / Yverdon-les-Bains https://www.appsec-forum.ch
  • 2.
  • 3. Bio • Cocoa developer • HES Software Engineer • MAS Eco. Crime Investigation • Twitter user since July, 2008 • Father of a newborn
  • 4. Agenda 1. Twitter 2. OAuth 3. Ripping Consumer Tokens 4. iOS / OS X + STTwitter 5. Discussion
  • 5. Tweets/day now $8 billion valuation, 340M top-10 most visited websites 140M 5000 1M 22 50 65 verified promo. Dick promo. no accounts trending tweets Costolo tweets more Twitter (celebrities) topics web CEO mobile RSS launch 2006 2007 2008 2009 2010 2011 2012 Tweetie TweetDeck stricter ToS, buyout buyout display guidelines last OS X client update v. 1.1 API OAuth API v. 1.0 HTTP Basic Authentication
  • 6. March 2013: Maximum Evilness “We’re trying to limit certain use cases that occupy the upper-right quadrant.” https://dev.twitter.com/blog/changes-coming-to-twitter-api
  • 7. The author’s name and @username must be displayed to the right of the avatar. • Reply, Retweet and Favorite Tweet actions must always be available. • No other 3rd party actions similar to Follow, Reply, Retweet may be attached to a Tweet. • The Twitter logo or Follow button for the Tweet author must always be displayed. • The Tweet timestamp must always be linked to the Tweet permalink. • A timeline must not be rendered with non-Twitter content. e.g. from other networks. https://dev.twitter.com/terms/display-requirements
  • 8. • Max. 100’000 users per Twitter client app. • “Twitter discourages development in this area” https://dev.twitter.com/terms/api-terms "Developers ask us if they should build client apps that mimic or reproduce the mainstream Twitter consumer client experience. The answer is no." "We need to move to a less fragmented world, where every user can experience Twitter in a consistent way." https://groups.google.com/forum/#! msg/twitter-development-talk/ yCzVnHqHIWo/sC34r_ZyMLYJ
  • 9. Developers ♥ Stupid Rules! "Twitter obviously wants to make money by advertising in the stream. This will be impossible if all of the mechanisms aren't implemented to spec within a client. They need full control of how the information is presented, and do not have the bandwidth to micromanage ads with third parties to prevent fraud, poor presentation, etc," http://www.theverge.com/2012/7/9/3135406/twitter-api-open-closed- facebook-walled-garden
  • 10. Breaking the Rules • OAuth authentication for every API request • "We reserve the right to revoke your app" https://dev.twitter.com/terms/api-terms • Can a rogue client spoof the identity of a regular client and use the API as it wants?
  • 11. Agenda 1. Twitter 2. OAuth 3. Ripping Consumer Tokens 4. iOS / OS X + STTwitter 5. Discussion
  • 13. @nst021 bitly Twitter “Use my account” request_token OAuth / Web authorize access_token home_timeline green coin is for bitly and @nst021
  • 14. @nst021 / iOS Twitter OAuth / Desktop request_token authorize access_token home_timeline green coin is for bitly and @nst021
  • 15. @nst021 / iOS Twitter Authentication request_secret request_token PIN: 3 phases request_key consumer_secret consumer_key authorize verifier access_secret access_token access_key home_timeline green coin is for bitly and @nst021
  • 16. @nst021 / iOS Twitter Authentication xAuth: 1 phase consumer_secret consumer_key access_secret access_token access_key username home_timeline green coin is password for bitly and @nst021
  • 17. Agenda 1. Twitter 2. OAuth 3. Ripping Consumer Tokens 4. iOS / OS X + STTwitter 5. Discussion
  • 18. /usr/bin/strings $ strings /Applications/Twitter.app/ Contents/MacOS/Twitter 3rJOl1ODzm9yZy63FACdg 5jPo**************************************
  • 19. Test the Tokens #!/usr/bin/env python import tweepy CONSUMER_KEY = '3rJOl1ODzm9yZy63FACdg' CONSUMER_SECRET = '5jPo**************************************' auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET) auth_url = auth.get_authorization_url() print "Please authorize:", auth_url verifier = raw_input('PIN: ').strip() auth.get_access_token(verifier) print "ACCESS_KEY:", auth.access_token.key print "ACCESS_SECRET:", auth.access_token.secret demo
  • 20. /usr/bin/gdb $ gdb attach <PID of OS X accountsd> (gdb) b -[OACredential consumerKey] (gdb) finish (gdb) po $rax tXvOrlJDmLnTfiUqJ3Kuw (gdb) b -[OACredential consumerSecret] (gdb) finish (gdb) po $rax AWcB**************************************
  • 21. /usr/bin/gdb $ gdb attach <PID of iPhoneSimulator accountsd> (gdb) b -[OACredential consumerKey] (gdb) finish (gdb) po (int*)$eax WXZE9QillkIZpTANgLNT9g (gdb) b -[OACredential consumerSecret] (gdb) finish (gdb) po (int*)$eax Aau5************************************** demo
  • 22. Logging Freed Strings $ sudo dtrace -n 'pid$target::free:entry { printf("%s", arg0 != NULL ? copyinstr(arg0) : "<NULL>"); }' -p 10123
  • 23. Objective-C Variant @implementation NSString (XX) + (void)load { Swizzle([NSString class], @selector(dealloc), @selector(my_dealloc)); } - (void)my_dealloc { NSLog(@"%@", self); [self my_dealloc]; } @end (gdb) p (char)[[NSBundle bundleWithPath: @"/Library/Frameworks/XX.framework"] load]
  • 24. Other Techniques • Memory dump $ sudo ./gcore64 -c /tmp/dump.bin 4149 $ strings dump.bin | sort -u > /tmp/dump.txt # key=consumerSecret& $ egrep "[a-zA-Z0-9]{20}&$" /tmp/dump.txt • Google…
  • 25. Agenda 1. Twitter 2. OAuth 3. Ripping Consumer Tokens 4. iOS / OS X + STTwitter 5. Discussion
  • 26. OS X Twitter Credentials Accounts.framework @nst021 xxxxxx
  • 27. can use OS X …or can use custom consumer tokens… consumer tokens STTwitterAPIWrapper + twitterAPIWith... - getHomeTimeline STTwitter - postStatus STTwitterOAuthProtocol STTwitterOAuth STOAuthOSX STHTTPRequest Accounts.framework Social.framework
  • 30. Agenda 1. Twitter 2. OAuth 3. Ripping Consumer Tokens 4. iOS / OS X + STTwitter 5. Discussion
  • 31. 1. Taking OAuth from web to Desktop was a conceptual error. Consumer tokens simply just cannot be kept secret on the Desktop. 2. Twitter cannot realistically revoke keys from popular clients, especially from OS X / iOS. 3. xAuth brings nothing more that HTTP Digest Authentication, and sends password in the request token phase. 4. OAuth cannot reliably identify the client, and additionally puts the users at risk. OAuth Session Fixation Attack Demo
  • 32.
  • 33. 5. I have to conclude that the real grounds for using OAuth is neither “security” nor spam fighting but desire to control third- party client applications to please big media, consumers and advertisers. 6. Sadly for Twitter, ensuring that the requests come from a certain client application is a very hard problem, and I am not sure if it can be solved.
  • 34. Recap 1. Twitter 2. OAuth 3. Ripping Consumer Tokens 4. iOS / OS X + STTwitter 5. Discussion
  • 35. Twitter: @nst021 Web: http://seriot.ch/abusing_twitter_api.php Slides: http://www.slideshare.net/ASF-WS/presentations