API Security Weekly: Issue 173
In this latest news update, read about Coinbase vulnerability, AuthN/AuthZ best practices, bad bots, and Elgato Key light hack.
Join the DZone community and get the full member experience.
Join For FreeThis week, we have news of the eye-opening vulnerability on the Coinbase platform which netted $250,000 in bug bounty. There’s also an excellent guide on best practices for authentication and authorization for REST APIs, an article on the growth of bad bots and how to mitigate against them, and a fun read from APIHandyman on how to hack the Elgato Key light API.
Vulnerability: Coinbase API Bug Allowed Unlimited Cryptocurrency Trading
This week’s major news story has been the disclosure of a major vulnerability in an API on Coinbase, a cryptocurrency trading platform. This vulnerability potentially allowed an attacker to make unlimited cryptocurrency trades between different currency accounts.
The vulnerability is a rather epic example of API1:2019 — Broken object-level authorization. To exploit the vulnerability, attackers needed two different cryptocurrency accounts and a modest balance in one account. Attackers could initiate a market order using the account with funds as the source account, but then could modify the API request to specify the other account with a low balance. Unfortunately, the Coinbase validation logic did not verify the source account properly and processed the trade normally. Thus, the attacker could complete the trade using cryptocurrency they did not in fact have.
The security researcher initially took to Twitter to publicize the potential issue to get in contact with the relevant security team at Coinbase. Once alerted, the response from Coinbase was exemplary, resulting in a complete resolution within 6 hours, and earning the security researcher a record $250,000 bounty. Coinbase themselves has covered the issue in their security blog, where they also describe additional compensating controls that would have reduced the impact.
Guide: Best Practices for API Authentication and Authorization
At 42Crunch, we recently featured a webinar focused on API authentication and authorization, an evergreen hot topic for API developers and security teams. This week, we have an excellent concise guide on this topic, courtesy of StackOverflow.
The key takeaways from the guide include the following:
- Always use TLS: Every API should use TLS (Transport Layer Security) without exception to prevent data leaks. While this introduces complexities in certificate management, modern platforms are moving to integrate certificate solutions to ease adoption.
- Use OAuth2 for single sign-on (SSO): OAuth2 has established itself as the de facto standard for authorization in SSO, with industry-standard providers like Google, GitHub, Microsoft, etc. By using OAuth2, developers can adopt standard flows for authentication well-designed to avoid common implementation errors, particularly if they also adopt standard OAuth libraries for their language/framework.
- Use API keys to give existing users programmatic access: For internal users with known identities, API keys can be used to simplify access to APIs without the complexity of OAuth2, as long as the keys are managed securely.
- Encourage using good secrets management for API keys: Do not commit any API keys to source code repositories — if necessary, use a secrets management solution.
- Choose when to enforce authorization with request-level authorization: Use authorization middleware to standardize access control and avoid broken function-level authorization vulnerabilities.
- Configure different permissions for different API keys: Be sure to use granular permissions on API keys to avoid giving unnecessary or unintended access.
- Leave the rest of the authorization to the app or business logic: If your application has particularly complex authorization requirements, consider using a standard library, such as OSOHq.
The single most important lesson worth repeating here for a developer is to leverage the power of standard libraries and frameworks as much as possible, not re-invent the wheel.
Article: The Rise of Bad Bots and How To Mitigate Against Them
NordicAPIs has contributed an interesting article on the rise of bad bots and how these are impacting APIs.
The article sheds light on how “sneaker bots” (because they automated the online purchase of sneakers on websites) were born, how they evolved to scrape Twitter accounts to gain access to market news a fraction before human users, and how they process this information.
From an adversarial viewpoint, the ability to automate API access facilitates easy attacks and the subsequent exfiltration of data once a vulnerability is discovered. To counteract this, the authors suggest several mitigation strategies against bots:
- Catch bad actors when they’re still in the reconnaissance stage
- Establish a baseline for human use of APIs
- Use an API gateway for rate limiting and to ban requests
- Have perimeter-level security beyond a gateway
- Avoid misconfigured APIs
- Make sure your authentication controls are up to scratch and limit access to potentially sensitive data wherever possible.
Article: How To Reverse Engineer and Hack the Elgato Key Light API
As a little self-indulgence (I’m an owner of an Elgato Key light) this week, we have a great write-up from the APIHandyman on hacking the Key light internal API. The article describes how to use the proxy feature in Postman to capture requests from the Elgato desktop application to the Key light. The author then demonstrates how the API can be enumerated using standard light operations.
Finally, the author makes some observations on the quality of the API design including:
- Values for light on/off were non-human readable values, prefer the use of “on” and “off”
- The brightness value did not seem to validate a minimum value, instead allowing zero as a valid value.
- For brightness values out of range (like 110%), a
HTTP 200 OK
code was returned rather than an error code as might be expected. - The color temperate values did not map to the Kelvin values on the UI, meaning that the user had to guess how the Kelvin value was derived internally.
All in all, a fun write-up showing some great Postman techniques and API design tips.
Published at DZone with permission of Colin Domoney. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments