APIs secured by design
Jose Manuel Luevano Reyes
Integration Consultant | API Design | Mulesoft Development | Software Developer | Remote Work
Introduction
Since the early design of computers, the main purpose has been to ingress, process, and egress data. Operating systems have ports opened for streams of data (under certain protocols) to be accessible for applications (code) to perform their functionalities. By design, security was not the initial priority; security arrived later when so many systems (applications) were already exchanging data across multiple platforms.
Antivirus, firewalls, gateways, web proxies, authorization validation, multifactor, and so many applications appeared to add the missing security layer, so systems can continue securely sharing data.
In the realm of your organization’s API platform, if your applications are exposed to the internet/public, hackers will do “API attacks”, and attempt to find a vulnerability; if they succeed in exploiting it, gain some access, and disrupt your entire API platform and your business. Hackers and Cybercriminals are engineering these attacks at a constant pace to discover a design flaw; to keep up, your organization must get advice from security experts and follow organizations; like Open Worldwide Application Security Project (OWASP, a nonprofit foundation that works to improve the security of software), who continuously updates its top 10 list for API Security Risks. Reading this list, some of them are the result of a software design phase that didn’t consider securely handling data. And all goes back to the design software phase.
Adding security to your applications helps, but API Attacks rely on direct access to public APIs to do any harm (if they use stolen credentials, the damage will be greater). As API Security is not part of your core business functions, your business team can’t keep up; the development team, confident that they have some security layer in place, may inadvertently design an application that is vulnerable. How to prevent this? One critical phase in any software design is the identification of non-functional requirements; where a specialized team can add a layer of security around your applications and other requirements (data models, volume, SLAs, etc.) that will set a strong foundation for your API platform.
From the OWASP top 10 APIs Security Risks, I will use API4:2023 Unrestricted Resource Consumption as inspiration for a couple of scenarios and provide some tips where non-functional requirements will help your organization have APIs secured by design.
Exposure of raw data
Don’t disclose raw data. Storing information in your systems (and sensitive data) may be a true necessity, but once your organization decides to store it, the challenge of keeping it safe is there. What non-functional requirement can you consider?
Scenario 1. You have the user’s date of birth stored in any of your systems, some attacker discovers an API method to request the user’s data. What should be in the API response?
Scenario 2. You have a unique identification (ID) for each customer, and it is internally used to get all data of your customer. A B2B application may need to have a subset of clients’ data stored inside their database, a unique ID is needed to assign an event/action to the same customer in both systems (or more systems). Later, the B2B application needs to post the event's outcomes for a specific customer back into your API.
How will you expose each customer’s ID in your API Platform to this external actor?
Things to consider:
Volume of information
The ability to store large amounts of data has become easy, scale-up is automatic, and this capacity of storage poses a risk, large volumes of data can be stolen if a flawed design allows it. Alternatively, by accepting large amounts of data in an uncontrolled manner, crippling your storage capacities (skyrocketing your cloud services billing).
Scenario 1. Your API exposes an operation over a resource “customer”; your API offers the option to include query parameters to narrow down the results or the opposite. If an Actor wants all your customer data, how must your API react?
Scenario 2. You allow posting/uploading files via a public API, and a bad Actor tries to exploit this functionality by saturating with all types of binary objects.
Things to consider:
Industry Applications
In general: Enable B2B applications to do business within your organization (API Platforms). Allow execution of business operations within handrails under SLAs and secure exchange of data.
Health: The patient’s subset data is being shared with the proper audience; each receives the necessary information to do their work: The family doctor will see some data, the pharmacist fulfilling prescriptions see another, and laboratories get another; lastly each can post/upload the data that is allowed to integrate into a patient’s record.
Retail: Enable seamless experience for customers buying online and in-store; while the customer's information is being kept safe and data is well integrated across stores and online.
领英推荐
Conclusion
Sharing information (data) among systems that trust each other, may make data security measures unnecessary, but new requirements arise, systems are added, data changes and platform communications changed; creating room for security flaws available to cybercriminals. If your organization has an API platform and changes are happening, then non-functional requirements are the way to always include API security measures in any enhancement. Lastly, follow security experts and organizations to be aware of the latest security threats to maintain your non-functional designs and a guaranteed way to have a secured API platform.
Takeaway: OWASP at https://owasp.org
ANNEX
B2B/B2C enabled by Mediation Pattern
Presentation layer:
After a security layer, Public/Internal APIs differentiate requests, these will adjust the operation and the response according to what is needed regarding data security safeguards.
Non-functional requirements will be taken care of:
Mediator layer:
Support operations (create, read, update, delete, etc.) over a resource (samples: Customer, Order, Employee, etc.).
Non-functional requirements will be taken care of:
System component layer:
Processing, System, and Backend Systems will execute operations over the exposed resources, using data received and aggregation/built a response.
Non-functional requirements will be taken care of:
Finally
For each layer, error responses may be different per type of API Consumer, like HTTP status code, and the response body may be manipulated.
Separation of concerns
It is a principle used in programming to separate an application into units, with minimal overlapping between the functions of the individual units. In the Mediation pattern, each layer represents a unit with unique functions over the data and its flow.
Summary
The Mediation Patterns allow each of your components to focus on small tasks; implement specific security measures, like the identification of actors, and adjust behavior according to non-functional requirements.
Director | National Lead - Digital Integration Practice & Alliances | PwC
1 年Really informative post Jose Manuel Luevano Reyes !! Secure by design a very important aspect for any transformational project and often organizations tend to look over.