8 best practices for microservices app sec | TechBeacon (2024)

There is virtually no situation in software architecture that entirely frees you from security considerations. With microservices,some issues becomemore distinct and a lot harder. However, there are also a few features of microservices that can bolster security.

Withmicroservices, the network is still a bottleneck. Things like identity and access control, which the industry already understands thoroughly within the realm of monolithic applications, assumes a new, almost unexpected, level of complexity.Thispaves the way for debates and scrutiny over whether a microservices architecture actually solves more problems than it creates. Yourdecision to use microservices should always be conditional.

When you've done your due diligence and decided that microservices are right for you, it's time to make sure that all of your applications' security demands are met. Here are eight best practices for securing yourmicroservices.

1. Use OAuthfor user identity and access control

The overwhelming majority of applications are going to need to perform some level of access control and authorization handling.What you want to avoid here is reinventing the wheel. OAuth/OAuth2 is practically the industry standard as far as user authorization goes. While building your own custom authorization protocol is clearly an option, many out there don't recommend it unless you have strong and very specific reasons for doing so.

While OAuth2isn't perfect, it's awidely adopted standard. The advantage of using it is that you can rely on libraries and platforms that will greatly accelerate your development phase. By the same token, several solutions for improving the security level of your OAuth-based authorization service have already been built by some of the biggest companies and smartest engineers around.

2. Use 'defence in depth' to prioritize key services

Assuming that a firewall on your network perimeter is enough to protect your software is a big mistake. "Defense in depth" is defined as "an information assurance concept in which multiple layers of security controls (defense) are placed throughout an information technology system."

In plain English, what you need to do is identify what your most sensitive services are, and apply a number of different layers of security to them, so that a potential attacker who is able to exploit one of your security layers will still have to figure out a way to beat all your other defenses on your critical services. This is by all accounts easier said than done, but several resources are available.

Security is typically a job better left to experts and not to amateurs. A proper defense in depth strategy is more likely to succeed if it's established by people who actually know what they're doing.

What's great about microservices is that they make it easier to adopt this strategy in a very granular and strategic way—by focusing your security efforts and resources on specific microservices. The architecture also makes it easier for you to diversify the layers of security you wish to adopt on each microservice. By so doing, an attacker who is able to exploit one of your servicesmay not necessarily be able to figure out how to exploit the second one.

3. Don’t write your own crypto code

Over the years, many people have invested incredible amounts of money, time, and resources into building libraries that handle encryption and decryption. If you hired 10 smart and competent security people, put them all in a room and asked them to come up with the best possible library for encryption and decryption, I doubt they would come up with something as good as the best open source crypto libraries that are already out there.

Most of the time, when it comes to security you shouldn't try to roll your own new solutions and algorithms unless you've got strong and specific reasons to, and you've got people skilled enough to create something nearly as good as the open source tools already available (tools that have been heavily battle tested by the community).

In most cases,you should useNaCl/libsodiumfor encryption. It's been around for several and it's fast, easy to use, and secure.While the original implementation of NaCl is written in C, it also supports C++ and Python. And thanks to the libsodium fork, several adapters for other languages like PHP, Javascript, and Goare available.

This section wouldn't be complete without mentioning the wildly popular Bouncy Castle library. If you're working with Java or C#, your best bet is to go with this one. If you want to learn more about encryption, read this developer's guide.

4. Use automatic security updates

If you want your microservices architecture to be secure and scalable at the same time, it's a good idea—in the early development phase—to figure out a way to automate or at least keep all of your software updates under control.

High testing coverage here is more essential than ever. Every time a part of your system is updated, you want to make sure you catch any issue early enough and in as much detail as possible.

Make sure that your platform is mostly "atomic". What that means is that everything should be wrapped within containersso that testing your application with an updated library or language version is just a matter of wrapping a different container around it. Should the operation fail, reversing everything is fairly easy and, most importantly, can be automated.

CoreOS, RedHat's Atomic Linux, and Ubuntu's Snappy Core are also projects you want to keep an eye on, as they try to bring about the same concept on an OS level.

5. Use a distributed firewallwith centralized control

For the most part, this is still uncharted territory, but I believe that afirewall that allows users more granular control over each and every microservice (as attempted by Project Calico) has got to be theway we build firewalls for microservices. If not now, at least at some point in the future.

6. Get your containers out of the public network

Amazon, with their AWS API gateway, probably made this whole notion more mainstream and easy to adopt than anyone else before.

An API gateway establishes a single entry point for all requests coming from all clients. It subsequently knows how to provide an interface forall of your microservices.

By using this technique you can secure all of your microservices behind a firewall, allowing the API gateway to handle external requests and then talk to the microservices behind the firewall.

Moreover, as the Netflix experience teaches us, using an API gateway is a great way to optimize requests based on the client, especially in the case of mobile devices.

7. Use security scanners for your containers

Within your automated testing suite, it would make sense to include periodic vulnerability and security scanning for your containers. The chief open source actor in this space appears to be Clair, from CoreOS. Docker Security Scanning and Twistlock are a couple of commercial options.

Something else to keep in mind here is that the container image itself may not necessarily be trusted unless its signature has been verified. rkt does that by default, while Docker introduced a similar feature a while ago after several security vulnerabilities were found.

8. Monitor everything with a tool

You can't afford to run a distributed system without a solid, advanced, and reliable monitoring platform. Several solutions are available out there, but the one that was built specifically with microservices in mind and has been around the block is Prometheus.

Built originally by engineers at SoundCloud, Prometheus is an open source monitoring platform and a part of the Cloud Native Computing Foundation. It's being supported and adopted by some of the biggest players in the industry, like SoundCloud themselves, CoreOS, and Digital Ocean.

Other monitoring solutions include InfluxDB, statsd and several well-known commercial platforms.

Don't reinvent the wheel

While the above is not intended to be an exhaustive list, it touches on the issues you are most likely to face when building applications based on a microservices architecture.

When it comes to security, reinventing the wheel is rarely a good idea. Always be researching the best practices adopted by the industry and suggested by experts.

Here are some additional resources I've bookmarked:

Share your best practices or resources on which you rely for securing microservices in the comments below.

Keep learning

8 best practices for microservices app sec | TechBeacon (2024)

FAQs

Which are some security best practices for a microservices architecture? ›

How to secure your microservices
  • Use authentication and authorization methods. ...
  • Control communication between microservices. ...
  • Prioritize container security. ...
  • Implement centralized monitoring. ...
  • Create an incident response plan. ...
  • Regularly review security measures.

Which of the following are the best practices for using microservices? ›

  • Follow the Single Responsibility Principle (SRP) ...
  • Define and maintain consistent service boundaries. ...
  • Do not share databases between services. ...
  • Use centralized observability tools. ...
  • Use an API gateway for HTTP. ...
  • Adopt a consistent authentication strategy. ...
  • Carefully consider your authorization options.

How to perform security testing in microservices? ›

How do you perform web security testing on a web application that uses a microservices architecture?
  1. Identify the scope and boundaries.
  2. Assess the risks and threats.
  3. Perform the tests and attacks.
  4. Analyze the results and findings.
  5. Recommend and implement the remediations.
  6. Repeat and automate the process.
Mar 12, 2023

Which authentication is best for microservices? ›

JWT (JSON Web Tokens)

JWT is a compact, URL-safe token format that can be digitally signed and optionally encrypted. It's widely used for authentication and authorization in microservices due to its statelessness and scalability.

How to securely communicate between microservices? ›

The first and most basic way to ensure secure communication between microservices is to use HTTPS and TLS protocols. HTTPS is the secure version of HTTP, which encrypts the data between the client and the server using SSL or TLS certificates.

What protocol is best for microservices? ›

Common Protocols Microservices Use in Communication
  • REST API Calls. REST API calls are common methods of microservices to communicate. ...
  • gRPC. gRPC, or Google Remote Procedure Call, is another high-performance protocol that enables microservices to effectively and efficiently communicate. ...
  • Message Brokers.
Oct 29, 2023

What are the best practices to design microservices ?( Multiple answers? ›

10 Best Practices for Microservices Architecture in 2024
  • Improve the Productivity with Domain-Driven Design. ...
  • Consider a Good Infrastructure. ...
  • Data Storage Separation is Must. ...
  • Migration. ...
  • Single Responsibility Principle. ...
  • Use API Changes that are Compatible. ...
  • Monitoring and Logging. ...
  • Develop a Splitting System.
Mar 18, 2024

How to improve microservices architecture? ›

Start small to understand the technical requirements of a distributed system, how to fail gracefully, and scale individual components. Then you can gradually extract more services as you gain experience and knowledge. The migration to a microservices architecture does not need to be accomplished in one holistic effort.

What are the weakness of microservices? ›

Decreased performance. A big disadvantage of microservices is that they consume more memory, clock-cycles and network bandwidth than a comparable monolithic architecture. A monolithic application runs all of its components within the scope of a single process.

What are the common risk with a microservice architecture? ›

In a microservices security architecture pattern, common risks and challenges include increased attack surface due to the distributed nature of services, potential vulnerabilities in communication between microservices, difficulty in enforcing consistent security policies across multiple services, and the complexity of ...

How do you troubleshoot microservices issues? ›

Here are some of the best practices for debugging microservices in any environment, whether using open source or commercial tools.
  1. Make Sure Your Logs are Searchable. ...
  2. Return Transactional References Back to the Client. ...
  3. Invest in Setting Up a Logging Framework. ...
  4. Consider Monitoring Tools.
Jun 9, 2020

Which of the following are best practices for microservices security? ›

Here are some best practices to be followed for improving security in microservices:
  • 1) API gateway is key. ...
  • 2) Robust defense strategy. ...
  • 3) Go the DevSecOps way. ...
  • 4) Avoid own crypto code. ...
  • 5) Security at services level. ...
  • 6) Secure with MFA. ...
  • 7) Verify dependencies. ...
  • How Veritis Can help?

How microservices can be monitored? ›

Developers use Kubernetes to define microservices and understand the state of deployed services. DevOps teams should configure alerts to focus on attributes closely related to the service experience. These alerts can immediately let operational staff know if anything is affecting the application or end users.

What kind of testing is required for microservices? ›

Summary Chart for Specific Types of Tests for Microservices
Type of TestWhat It Does
Component TestRuns the microservice as a black box, testing the interface's behavior.
Integration TestStimulates interaction between modules; tests that the microservice works with the other REAL microservices involved.
2 more rows
May 10, 2023

Which of the following are security best practices? ›

Top 10 Security Practices
  • Log off public computers. ...
  • Back up important information ... and verify that you can restore it. ...
  • Keep personal information safe. ...
  • Limit social network information. ...
  • Download files legally. ...
  • Ctrl-ALt-Delete before you leave your seat! ...
  • Secure your laptop, smart phone or other mobile devices.

Which of these concepts are essential to microservices security? ›

Container security is critical in cloud-native environments where microservices reside. Container security risks can compromise container images, registries, orchestration, host OS, and more. In the container environment, application images are the most vulnerable areas.

Which security mechanism is commonly used to secure inter-service communication in microservices? ›

One of the most basic and essential steps for securing inter-service communication is to use HTTPS and TLS protocols. HTTPS encrypts the data in transit, preventing eavesdropping or tampering by malicious actors.

What are the common risk with a Microservice architecture? ›

In a microservices security architecture pattern, common risks and challenges include increased attack surface due to the distributed nature of services, potential vulnerabilities in communication between microservices, difficulty in enforcing consistent security policies across multiple services, and the complexity of ...

Top Articles
How Long Should Blog Posts Be in 2021? [New Data]
Effigy of Grief
How To Start a Consignment Shop in 12 Steps (2024) - Shopify
123Movies Encanto
DEA closing 2 offices in China even as the agency struggles to stem flow of fentanyl chemicals
Best Transmission Service Margate
Unraveling The Mystery: Does Breckie Hill Have A Boyfriend?
Big Y Digital Coupon App
Atrium Shift Select
Kostenlose Games: Die besten Free to play Spiele 2024 - Update mit einem legendären Shooter
Which aspects are important in sales |#1 Prospection
Www.paystubportal.com/7-11 Login
Mills and Main Street Tour
Dumb Money, la recensione: Paul Dano e quel film biografico sul caso GameStop
How do I get into solitude sewers Restoring Order? - Gamers Wiki
Nevermore: What Doesn't Kill
Daytonaskipthegames
Iroquois Amphitheater Louisville Ky Seating Chart
Reptile Expo Fayetteville Nc
Laveen Modern Dentistry And Orthodontics Laveen Village Az
Optum Urgent Care - Nutley Photos
All Obituaries | Verkuilen-Van Deurzen Family Funeral Home | Little Chute WI funeral home and cremation
Elbert County Swap Shop
How To Tighten Lug Nuts Properly (Torque Specs) | TireGrades
Vivaciousveteran
Mineral Wells Skyward
Enduring Word John 15
Stockton (California) – Travel guide at Wikivoyage
Calvin Coolidge: Life in Brief | Miller Center
Wisconsin Volleyball Team Leaked Uncovered
Craigslist Free Stuff San Gabriel Valley
Everstart Jump Starter Manual Pdf
Royals op zondag - "Een advertentie voor Center Parcs" of wat moeten we denken van de laatste video van prinses Kate?
Today's Final Jeopardy Clue
How to Destroy Rule 34
The Boogeyman Showtimes Near Surf Cinemas
Ishow Speed Dick Leak
Elizaveta Viktorovna Bout
Ross Dress For Less Hiring Near Me
Courtney Roberson Rob Dyrdek
Dragon Ball Super Super Hero 123Movies
How To Get To Ultra Space Pixelmon
Greatpeople.me Login Schedule
Rocket League Tracker: A useful tool for every player
antelope valley for sale "lancaster ca" - craigslist
Diablo Spawns Blox Fruits
Maurices Thanks Crossword Clue
Samantha Lyne Wikipedia
Minecraft Enchantment Calculator - calculattor.com
Swissport Timecard
What Responsibilities Are Listed In Duties 2 3 And 4
Latest Posts
Article information

Author: Greg O'Connell

Last Updated:

Views: 5718

Rating: 4.1 / 5 (42 voted)

Reviews: 81% of readers found this page helpful

Author information

Name: Greg O'Connell

Birthday: 1992-01-10

Address: Suite 517 2436 Jefferey Pass, Shanitaside, UT 27519

Phone: +2614651609714

Job: Education Developer

Hobby: Cooking, Gambling, Pottery, Shooting, Baseball, Singing, Snowboarding

Introduction: My name is Greg O'Connell, I am a delightful, colorful, talented, kind, lively, modern, tender person who loves writing and wants to share my knowledge and understanding with you.