Issue 102: Vulnerabilities in Facebook and campaign apps, creating defensible APIs 🛡️

The Latest API Security News, Vulnerabilities and Best Practices
Issue: #102
Vulnerabilities in Facebook and campaign apps, creating defensible APIs
This week, we look into the recent API vulnerabilities at Facebook and the campaing apps for US presidential election, a new book on the OpenAPI Specification (OAS), and a guest post by API security trainer Mohammed Aldoub on how to build APIs that are easy to defend against attackers.
Vulnerability: Facebook
 

Marcos Ferreira found a Broken Object-Level Authorization (BOLA/IDOR) vulnerability in Facebook’s GraphQL API.  The vulnerability allowed anyone to change the URL of a Facebook Page (so not your Facebook profile or user account), and then take over the old URL.

Facebook allows page admins to create a “username” for their page, so that the URL of the page would be more human-readable, instead of using the page ID.

The API for that posts a JSON with the page ID and the “username” you want to assign to it:

The attackers could simply find the page ID of their intended victim and send an API call for creating a username for a Facebook Page using this page ID.

POST /api/graphql/ HTTP/1.1
Host: facebook.com

fb_api_req_friendly_name=PagesCometAdminEditingUsernameMutation&

doc_id=2886327251450197&

variables={"input":
{"end_point":"comet_left_nav_bar",
"entry_point":"comet",
"page_id":"0",
"skip_save_for_validation_only":false,
"username":"TEST123456",
"actor_id":"0",
"client_mutation_id":"9"
}
}

Change page_id with your target’s Page ID

Response

"data": { 
"page_edit_username": {
"error": null,
"username": "TEST123456"
}
}

As the result, the URL of the existing page gets changed to the username in the API call, leaving the attackers free to use the recently vacated URL on their own Facebook Page.

With social media playing bigger and bigger part in how people get their information, are influenced, and do business the possible gains (including monetary) for attackers could be significant. Fake profiles and pages impersonating as public figures and businesses have long been a problem in Facebook, so this looks like just another way in.

Facebook has since fixed the issue.

The best way to avoid these kind of issues is naturally to make sure that you have object-level authorization in place not letting anyone make changes that they are not supposed to make.

Vulnerability: US presidential election campaign apps
 

The US presidential elections are fast approaching, and campaigning is on the final stretch. In this time and era, there obviously is an app for it. Among more traditional analysts, application security specialists have been looking into the campaigns as well. In neither case did they come away empty-handed.

Researchers behind “The App Analyst” blog analyzed the apps for both campaigns and found security issues in both of them. The Biden app was more complex in terms of its functions, and had a couple of API security flaws, namely Excessive Data Exposure:

1. JSON object returned for each object contained more data than the user interface exposed – for example it included projected voting history and date of birth:

2. They also had API that the app could make to submit information from user contacts. That API was returning data not used by the app but containing pretty sensitive information including home address:

The vulnerabilities were responsibly disclosed and fixed within few days.

Meanwhile, Website Planet discovered that the more basic Trump app exposed several API keys to different parts of the app in its Android APK file. These keys in turn could have potentially allowed attackers to impersonate the app (for example, Tweet on behalf of the campaign), or even potentially access user data. In this, too, the vulnerabilities were fixed within days of being reported.

Don’t put your API keys in the app and don’t expose in your APIs more data than you are OK with users seeing.

Book: Designing APIs with Swagger and OpenAPI
 

Formal, machine-readable API definitions are key to security automation, and OpenAPI (aka Swagger) is by far the dominant standard here.

You can learn more about the standard and its practical use in Josh Ponelat’s book “Designing APIs with Swagger and OpenAPI” (Manning Books).

It’s a great hands-on primer for describing, planning, and designing web APIs, from planning and tools to developing and documenting your API. The book is still work in progress and if you subscribe, you can get chapters as they get out (and the full book after it’s done.)

Use the coupon code 42Crunch40 to get 42% off at the checkout.

Opinion: Creating defensible APIs
 

Bmjm4_2t_400x400The text below was Mohammed Aldoub‘s contribution to our 100th newsletter issue. The text was definitely much longer and much more detailed than what the format of that issue could allow, so we decided to put it on its own in one of the later newsletters: this one 😉

Mohammed is a well-known API security trainer known, for example, for his 2-day API security classes at Black Hat conferences. Below is a quick summary of the key points that he teaches in his classes. To learn more, we highly recommend joining them.

 

APIs need to be easy to use right, and hard to use wrong.

Easy to use securely, and hard to use insecurely.

But how?

Approaches:

  • Secure defaults.
  • Strict data validation
  • Adherence to standards/expectations/conventions.
  • Clear documentation
  • Logging and Monitoring

Secure defaults

If you design a feature to be secure by default, you will worry less about API consumers’ levels of experience, trust or interest in security.

Secure defaults provide us with better protections against novice mistakes, incomplete assumptions and rushed deployments.

Examples of secure defaults:

  • Using default strong password hashing and storage methods.
  • Auto-generated administration passwords instead of default passwords.
  • Encoding all output data by default, unless requested otherwise.

Strict data validation

Making sure your API only accepts a verified format of input and output data results in more secure APIs.

Examples of strict data validation:

  • Strict validation of input data according to one format (JSON or XML)
  • Strict declaration of expected input and output elements, and discard for any unexpected or extra elements.
  • Conforming data to certain lengths or content-types.
  • Validation of digital signatures and integrity codes (Hash, Mac)

Adherence to standards/expectations/conventions

The less assumptions API consumers have to make about your API, the less chances exist for abuse and exploitation. A secure API needs to pull no surprises or weird behavior.

Examples include:

  • Utilizing and respecting HTTP standard features:
    • Never change state/data on a GET or HEAD request.
    • Create new resources with POST.
    • Update specific resources with PUT or POST.
    • Respecting HTTP caching headers.
    • Proper data content-types (json, xml, text… etc)

Clear documentation

If a feature is not very well documented in writing, API users will still document it in their heads (or their internal wikis!) based on what they assume, understand or test.

Where there are assumptions, there are vulnerabilities.

Documentation must be very clear on:

  • Unsafe methods that should only be used in certain circumstances.
    • E.g. methods that output unvalidated data.
    • For example: ReactJS’s dangerouslySetInnerHTML
  • Edge cases that need to be handled or understood by developers.
  • Errors and exceptions

Logging and monitoring

An API needs to have advanced, multi-level logging capabilities and methods.

Suggested Log levels for APIs:

  • Detailed, for debugging purposes.
  • Production, just enough details but no sensitive info and redacted PII (Personally Identifiable Information) especially passwords.
  • Basic, for statistics, anomaly analysis and business tracking.

Logging formats:

  • Cloud provider logs  (e.g. AWS CloudWatch)
  • Logging provided by language/framework.
  • Web server logging format.
  • Some services (CDN, Cloud, WAF) also log in JSON format.
  • OS level logging (e.g. Windows Event Logs)

Logging has very significant security impact, mainly in two ways:

  • Logging Security-related events.
  • Securing the log data itself.

Logs can determine attack sources, attack payloads, exploits used, and also whether or not attacks were successful and data was stolen.

It’s therefore essential to log suspicious request and responses, and also essential to protect the logs themselves just as well as we protect the databases.

Solutions to protect logs:

  • Never logging sensitive data fully (Passwords …. Etc)
  • Apply access controls to determine who’s allowed to read logs.
  • Encrypt logs at rest and transmit, and securely archive old log files.
  • Periodically review what gets logged
  • Protect systems that handle log files: Log aggregation, log analysis and log transmission. E.g. Protect Apache Solr and ElasticSearch & Kibana endpoints.
  • Also log access attempts to the logs themselves! Know who viewed the logs and what for!
 
dmitry_apisec-1  

Dmitry Sotnikov

APIsecurity.io

 
Thanks for reading.

That's it for today. If you have any feedback or stories to share, simply reply to this email.

Please forward the newsletter to your friends and colleagues who might benefit from it.

 
42Crunch Ltd   71-75 Shelton Street  Covent Garden  London  Greater London   WC2H 9JQ   United Kingdom
You received this email because you are subscribed to API Security News from 42Crunch Ltd.

Update your email preferences to choose the types of emails you receive or Unsubscribe from all future emails  
 
 

Older messages

Issue 101: Vulnerabilities in Giggle, Google Cloud Platform, SonicWall, New Relic, Tesla 🚗

Thursday, September 17, 2020

Hi, today we cover 5 recent API vulnerabilities, IDOR cheatsheet & 2 upcoming events APIsecurity.io The Latest API Security News, Vulnerabilities and Best Practices Issue: #101 Vulnerabilities in

API Security advice from top industry experts | Nano Leaf Giveaway! 🎆

Thursday, September 10, 2020

Hi, in our centennial edition we hear API security advice from 12 top industry experts! APIsecurity.io The Latest API Security News, Vulnerabilities and Best Practices Issue: #100 API Security advice

Issue 99: API flaws in the Mercedes-Benz app and Russian inter-bank money transfer

Friday, September 4, 2020

Hi, this week we look at two recent API vulnerabilities, upcoming ACS 2020, and IIoT APIsecurity.io The Latest API Security News, Vulnerabilities and Best Practices Issue: #99 API flaws in the Mercedes

Issue 98: APIs as the next frontier in cybercrime

Thursday, August 27, 2020

Hi, today we look at a couple recent vulnerabilities, what makes APIs such a target, an APIsecurity.io The Latest API Security News, Vulnerabilities and Best Practices Issue: #98 APIs as the next

Issue 97: How to not leak API keys

Thursday, August 20, 2020

Hi, today we look at 2 recent API vulnerabilities, a CTF breakdown, and a DEF CON talk APIsecurity.io The Latest API Security News, Vulnerabilities and Best Practices Issue: #97 Gym apps & home

You Might Also Like

You’re invited: Start your generative AI journey

Tuesday, May 7, 2024

Build a search solution that goes beyond text and recognizes the meaning behind queriesㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ elastic | Search. Observe. Protect Getting

Happening TUESDAY! Follow Our Coverage of Apple’s Spring Announcement

Monday, May 6, 2024

iPhone Life magazine Follow Our Coverage of Apple's Latest Announcement. twitter facebook YouTube Podcast Tune in for Apple's 'Let Loose' Event Tomorrow! Surprise! Just a month before

Who wants a new iPad?

Monday, May 6, 2024

Plus: OpenAI and Stack Overflow partner and LockBit's website returns View this email online in your browser By Christine Hall Monday, May 6, 2024 Good afternoon, and welcome back to TechCrunch PM.

🔋 Why You Need More Than One Power Bank — Things We Want to See in Windows 12

Monday, May 6, 2024

Also: 7 Samsung Messages Features You Should Be Using, and More! How-To Geek Logo May 6, 2024 Did You Know You can find all manner of canned vegetables, but not broccoli: the temperatures required for

Launch pad decongestion

Monday, May 6, 2024

We've got some very cool news from Hubble Networks, which became the first company to connect a Bluetooth chip to a satellite. View this email online in your browser By Aria Alamalhodaei Monday,

Daily Coding Problem: Problem #1433 [Medium]

Monday, May 6, 2024

Daily Coding Problem Good morning! Here's your coding interview problem for today. This problem was asked by Nest. Create a basic sentence checker that takes in a stream of characters and

Want to become an AI consultant?

Monday, May 6, 2024

My take on this new industry ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌

Visualized | Interest Rate Forecasts for Advanced Economies 📈📉

Monday, May 6, 2024

In this graphic, we show the IMF's interest rate forecast for the US, Europe, the UK, and Japan for the next five years ahead. View Online | Subscribe Presented by Voronoi: The App Where Data Tells

⚙️ Apple AI updates

Monday, May 6, 2024

Plus: X AI stories & YouTube "skip to the good part" ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌

Unlock Time Series Data, FTC Chair Joins StrictlyVC & More

Monday, May 6, 2024

TechCrunch Events Roundup | May 6 TechCrunch Events TechCrunch events roundup Unlock the power of time series data with industry experts from AWS and InfluxDB on May 16. Join us next week for this free