{'fraction_non_alphanumeric': 0.026351697083404402, 'fraction_numerical': 0.008442776735459663, 'mean_word_length': 5.27072192513369, 'pattern_counts': {'":': 1, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Smells and Refactorings for Microservices Security: A Multivocal Literature Review

Context: Securing microservice-based applications is crucial, as many IT companies are delivering their businesses through microservices. If security smells affect microservice-based applications, they can possibly suffer from security leaks and need to be refactored to mitigate the effects of security smells therein. Objective: As the currently available knowledge on securing microservices is scattered across different pieces of white and grey literature, our objective here is to distill well-known smells for securing microservices, together with the refactorings enabling to mitigate the effects of such smells. Method: To capture the state of the art and practice in securing microservices, we conducted a multivocal review of the existing white and grey literature on the topic. We systematically analyzed 58 studies published from 2014 until the end of 2020. Results: Ten bad smells for securing microservices are identified, which we organized in a taxonomy, associating each smell with the security properties it may violate and the refactorings enabling to mitigate its effects. Conclusions: The security smells and the corresponding refactorings have pragmatic value for practitioners, who can exploit them in their daily work on securing microservices. They also serve as a starting point for researchers wishing to establish new research directions on securing microservices.


INTRODUCTION
Microservices are on the rise for architecting enterprise applications nowadays, with big players in IT (e.g., Amazon, Netflix, Spotify, and Twitter) already delivering their core businesses through microservices [80]. This is mainly because microservice-based applications are cloud-native, thus better exploiting the potentials of cloud hosting, and since they fully twin with DevOps and continuous delivery practices [2]. Microservices also bring various other advantages, such as ease of deployment, resilience, and scalability [52]. Together with their gains, however, microservices bring also some pains, and securing microservice-based applications is certainly one of those [76].
Microservice-based applications are essentially service-oriented applications adhering to an extended set of design principles [88], e.g., shaping services around business concepts, decentralisation, and ensuring the independent deployability and horizontal scalability of microservices, among others. Such additional principles make microservice-based applications not only serviceoriented, but also highly distributed and dynamic. As a result, other than the classical security issues and best-practices for service-oriented applications, microservices bring new security challenges [76]. For instance, being much more distributed than traditional service-oriented applications, microservice-based application expose more endpoints, thus enlarging the surface prone to security attacks [39]. It is also crucial to establish trust among the microservices forming an application and to manage distributed secrets, whereas these concerns are of much less interest in traditional web services or monolithic applications [85]. Another example follows from the many communications occurring among the microservices forming an application, which -if not properly handled-can result in message data being intercepted and in malicious users inferring business operations from such data [86].
Whereas there exist quite much literature on securing microservices, different pieces of literature deal with different aspects of security. As a result, the currently available information on securing microservices is scattered among a considerable amount of books, blog posts, research papers, videos, and whitepapers. This hampers consulting the body of knowledge on the topic, both for academic researchers wishing to delineate novel research directions and solutions for securing microservices, and for practitioners daily needing to secure microservice-based applications. To help both researchers and practitioners, this paper tries to organise the scattered knowledge on securing microservices, by answering to the following two research questions: (RQ1) Are there well-recognised smells indicating possible security violations in microservicebased applications? (RQ2) How to refactor microservice-based applications to mitigate the effects of security smells therein?
An architectural smell can be observed in the architecture of an application, and it is the effect of a bad decision (though often unintentional) while architecting the application, which may negatively impact on the overall system quality [20]. The effects of architectural smells can be mitigated by refactoring the internal structure of an application or the functionalities of its internal components, while at the same time not changing the functionalities it offers to its external clients. Even if applying a refactoring requires some development efforts, it is known that refactorings mitigating the effects of architectural smells will most probably improve the overall system quality [20].
To answer to our research questions, we systematically analyzed the available literature on securing microservices to elicit well-known smells, which may possibly result in security violations in microservice-based applications. We also elicited the refactorings that are known to mitigate the effects of security smells. In particular, following the recommendations by Garousi et al. [23], we captured both the state of the art and the state of practice in the field by conducting a multivocal review of the existing literature. We analysed both white literature (viz., peer-reviewed papers) and grey literature (viz., blog posts, industrial whitepapers, books, and videos). We carefully selected 58 studies published since 2014 (when microservices were first introduced in Lewis and Fowler's blog post [41]) until the end of 2020, which we then systematically analysed by following the guidelines for conducting systematic reviews [24,60]. As a result, we obtained a taxonomy that organises the identified security smells together with all refactorings that should be enacted to mitigate their effects. Finally, we exploited the taxonomy to classify the selected studies, in order to distill the actual recognition of the identified smells and of their corresponding refactorings.
In this paper, we illustrate the results of our multivocal review. We first present the taxonomy of security smells, including ten security smells and ten refactorings, organised around three security properties defined in the ISO/IEC 25010 standard for software quality [31], viz., integrity, authenticity, and confidentiality. Then we discuss each security smell by illustrating why it can possibly violate the security property it is associated with. For each smell, we also discuss the corresponding refactorings recommended by practitioners, by also explaining how such refactoring enables mitigating its effects.
We believe that the results of our study can provide benefits to both researchers and practitioners interested in microservices. A systematic presentation of the state of the art and practice on wellknown security smells for microservices provides a body of knowledge to develop new techniques and solutions, to investigate and experiment research implications, and to set future research directions. At the same time, it can help practitioners to better understand the currently most recognised security smells for microservices, and to enact the corresponding refactorings to mitigate their effects. This is of pragmatic value for practitioners, who can use our study as a starting point for securing their microservice-based applications, as well as a reference in their day-by-day work with microservices. The rest of this article is organised as follows. Section 2 illustrates the process enacted to select the reference studies. Section 3 presents the taxonomy of security smells and describes them in detail, together with the refactorings enabling to mitigate its effects. Section 4 discuss the potential threats to the validity of our study and how we dealt with them.

SEARCH FOR STUDIES
The objective of this multivocal review is to identify the possible security smells for microservicebased applications, and the refactorings enabling to mitigate their effects. With the objective of capturing the state of the art and practice in the field, we searched for both white literature (viz., peer-reviewed journal and conference articles) and grey literature (viz., blog posts, industrial whitepapers, books, and videos), in line with what recommended by Garousi et al. [23].
The structuring of the search string was done by following the guidelines provided by Petersen et al. [60]. We identified the search string guided by the PICO terms of our research problem, with search keywords taken from each aspect of our research problem. We anyhow decided -differently from what indicated by Petersen et al. [60]-to not restrict our focus to specific research settings. If restricted to given types of research settings, the results of our analysis could have been biased or incomplete, since some security smells or refactorings might have been over-represented or under-represented in certain types of study.
The search of white literature was carried out in the following indexing databases: ACM Digital Library, DBLP, EI Compendex, Google Scholar, IEEE Xplore, INSPEC, ISI Web of Science, Science Direct, and SpringerLink. Given the recency of microservice-related studies and the well-known concerns with indexing, Google Scholar played a key role for the initial selection before the inclusion and exclusion stage. The search for grey literature was instead carried out in the following search engines: Google, Bing, and DuckDuckGo. Given the amount of results returned by the different combinations of the keywords in the search string (often, hundreds of thousands), and given that each search was repeated on each considered search engine, we adopted the effort bounded stopping criteria suggested by Garousi et al. [24]. In particular, for each search on each search engine, we considered the top 250 search hits (e.g., the first 25 pages of results returned by the Google search engine).
The above described search criteria were matched by 136 studies, which we carefully screened to keep only those studies that were satisfying at least one of the following inclusion criteria: • A study is selected if it presents at least one security smell possibly resulting in a violation of a security property defined by the ISO/IEC 25010 software quality standard [31], such as confidentiality, integrity, and authenticity. • A study is selected if it presents at least one refactoring for mitigating the effects of a security smell, even if the latter is not explicitly mentioned. The inclusion criteria were defined with the ultimate goal of selecting representative studies, discussing the security smells for microservices or their corresponding refactorings. In addition, we decided to keep only one instance of each representative study, in case they were replicated across multiple pieces of literature, as this often happen in the case of grey literature (e.g., we removed [21] and [64] from consideration, as they were replicating [22] and [63], respectively). As a result, 58 studies were selected to be analysed further. The selected studies are listed in Table 1 by providing a reference to their full bibliographic information available in the references listed at the end of this article. The table also classifies each selected study by publication year, colour, and type. Figure 1 illustrates a taxonomy for the security smells pertaining to the considered security properties, and for the refactorings allowing to mitigate such smells. We obtained our taxonomy by following the guidelines for conducting systematic reviews in software engineering proposed by Petersen et al. [60]:

MICROSERVICES SECURITY SMELLS AND REFACTORINGS
(1) We identified the security smells by performing a first scan of the selected studies.
(2) We excerpted the refactorings directly from the selected studies after additional scans.
The obtained security smells and refactorings were then manually organized to obtained a taxonomy. A first version of the taxonomy was obtained by grouping the security smells based on the security properties they pertain to, by taking the security properties defined in the ISO/IEC 25010 standard [31] as a reference. Out of the five properties defined in the ISO/IEC 25010, only three of them resulted to be directly corresponding to some of the identified security smells. These are confidentiality (viz., the degree to which a product or system ensures that data are accessible only to those authorized to have access), integrity (viz., the degree to which a system, product, or component prevents unauthorized modification of computer programs or data), and authenticity (viz., the degree to which the identity of a subject or resource can be proved to be the one claimed). The taxonomy of security properties, smells, and refactorings underwent various iterations among   the authors of this study. This resulted in some corrections and amendments to the first version of the taxonomy, which resulted in the final version of the taxonomy displayed in Figure 1. In the taxonomy, the refactorings associated to a smell should all be applied to mitigate its effects. Table 2 shows the classification of all selected studies based on the taxonomy in Figure 1. The table provides a first overview of the coverage of the security smells over the selected studies. Such coverage is also displayed in Figure 2, from which we can observe that all security smells in the taxonomy are significantly recognized by the authors of the selected studies, hence making it worthy to discuss them in detail. We hereafter discuss each identified security smell, by also highlighting how (as per what emerges from the selected studies) such smell may result in violating the corresponding security properties, as well as how each smell can be mitigated by applying a corresponding refactoring.

Insufficient Access Control
The Insufficient Access Control smell occurs whenever a microservice-based application does not enact access control in one or more of its microservices, hence possibly violating the Confidentiality of the data and business functions of the microservices where access control is lacking [10,81]. If this smell is present, microservices can get exposed to, e.g., the "confused deputy problem", with attackers that can trick a service and get data that they should not be able to get [53]. At the same time, microservices are not suitable for traditional identity control models, since client details and permissions need to be verified as and when a request is sent [17], and they need a way to automatically decide whether to allow or reject calls between services [87]. In addition, microservices require development teams to establish and maintain the identity of users without introducing extra latency and contention with frequent calls to a centralized service [28]. From the 25 studies describing the Insufficient Access Control smell, it turns out that the effects of this smell can be mitigated if development teams Use OAuth 2.0. Open Authorization (OAuth) 2.0 [29] is indeed the most used mechanism to manage access delegation. OAuth 2.0 is a token-based security framework for delegated access control that lets a resource owner grant a client access to a certain resource on their behalf. This access is for a limited time and with limited scope [47]. OAuth 2.0 is hence a natural candidate to enforce access control in microservice-based application at each level, therein included controlling the accesses to each microservice [40].

Publicly Accessible Microservices
The Publicly Accessible Microservices smell occurs whenever the microservices forming an application are directly accessible by external clients [46,55]. Each microservice can be accessed independently through its own API, and it needs a mechanism to ensure that each request is authenticated and authorized to access the set of functions requested [1]. However, if each microservice performs authentication individually, the full set of a user's credentials is required each time, increasing the likelihood of Confidentiality violations (e.g., with the exposure of long-term credentials) and reducing the overall maintainability and usability of the application. Also, each microservice is required to enforce the security policies that are applicable across all functions of the microservice-based application [47].
The Publicly Accessible Microservices smell is discussed in 25 out of the 58 selected studies. The authors of such 25 studies highlight that development teams can mitigate the effects of the Publicly Accessible Microservices smell if they Add an API Gateway. This enables to identify a set of microservices to be exposed through the newly introduced API Gateway, while the rest of the microservices are made unreachable from outside this domain. The API gateway centrally enforces security for all the requests entering the microservices application, including authentication, authorization, throttling, and message content validation for known security threats [73]. For instance, as we shall discuss in Section 3.9, the API gateway can be used to implement a single sign-on to the application. In addition, by using this approach development teams can also secure all microservices behind a firewall, allowing the API gateway to handle external requests and then communicate with the microservices behind the firewall [55]. Since the clients do not directly access the services, they cannot exploit the services on their own [35].

Unnecessary Privileges to Microservices
The Unnecessary Privileges to Microservices smell occurs when microservices are granted unnecessary access levels, permissions, or functionalities that are actually not needed by such microservices to deliver their business functions [1,10]. The Unnecessary Privileges to Microservices smell is described in 12 out of the 58 selected studies, all highlighting how such additional privileges given to microservices would potentially result in Confidentiality and Integrity issues. This happens, e.g., when a service can write or read data stored in databases or messages posted in messages queues, even if such databases or queues are not needed by the service to deliver its business function. As a result, resources are unnecessarily exposed, hence unnecessarily increasing the attack surface for Confidentiality and Integrity leaks: an intruder taking control of a service can indeed start reading or modifying all data and messages the service can access to [39].
The authors of the studies describing the Unnecessary Privileges to Microservices smell also highlight that development teams can mitigate its effect if they Follow the Least Privilege Principle. The latter recommends that accounts and services should have the least amount of privileges they need to suitably perform their business function [32]. This principle should be used because even if a development team has ensured that the machine-to-machine communication is secured and there are appropriate safeguards with their firewall, there is always the risk that an attacker gets access to the microservice-based application [5,32]. Development teams should indeed limit service privileges, by providing each service with access to only the resources they actually need to deliver their business functionalities.

Own Crypto Code
It is well-known that Confidentiality, Integrity, and Authenticity of data in software applications can get violated if development teams use their Own Crypto Code, viz., their own new encryption solutions and algorithms, unless they have been heavily tested [36,55]. The authors of nine out of the 58 selected studies emphasize that microservice-based applications are not the exception: development teams that implement their own encryption solutions may end with improper solutions for securing microservices, which may result in possible Confidentiality, Integrity, and Authenticity issues. The use of Own Crypto Code may actually be even worse than not having any encryption solution at all, as it may produce a false sense of security [52].
In all the studies describing the Own Crypto Code smell, the authors point out that the way to mitigate this smell is through the Use of Established Encryption Technologies. In other words, development teams should minimize the amount of encryption code written and maximize the amount of code that they can leverage from "bullet proof" libraries, which have already been heavily tested by the community [21,55]. Development teams should also avoid the use of experimental encryption algorithms, as they may be subject to various kinds of vulnerabilities, which may be not yet known at the time of their use. Whatever are the programming languages used to implement the microservices forming an application, development teams always have access to reviewed and regularly patched implementations of established encryption algorithms [52].

Non-Encrypted Data Exposure
The Non-Encrypted Data Exposure smell occurs when a microservice-based application accidentally expose sensitive data, e.g., because it was stored without any encryption in the data storage, or because the employed protection mechanisms are affected by security vulnerabilities or flaws [5,52]. When sensitive data is exposed, its Confidentiality and Integrity can get violated because it could be acquired or modified by an intruder who gets direct access to the microservices forming an application. As a result, the intruder may access to or manipulate, e.g., some credentials for accessing other systems or business-critical data [28].
From the 12 selected studies that describe the Non-Encrypted Data Exposure smell, it emerges that development teams can mitigate the effects of this smell if they Encrypt all Sensitive Data at Rest, viz., when data is not actively moving from device to device or network to network, e.g., when data is stored on a hard drive. The microservice-based architectural style enables development teams to separate functions from data in each of the microservices of an application [53]. As a recommendation, all sensitive data should always be encrypted, and it should be decrypted only when it needs to be used. Most database management systems provide features for automatic encryption, and disk-level encryption features are available at the operating-system level [73]. Application-level encryption is another option, in which the application itself encrypts the data before passing it over to the file system or a database. Finally, if a caching technology is used and the data is encrypted in the database, then development teams need to ensure that the same level of encryption is applied to such caching technology [32].
At the same time, development teams should also keep in mind that encryption is a resourceintensive operation that could have a considerable impact on the application performance [73]. As not all data needs the same level of security, and since in a microservice-based application it is common to have multiple data stores, development teams must perform a proper analysis to identify the critical ones and encrypt them.

Hardcoded Secrets
The Hardcoded Secrets smell occurs when a microservice of an application has hard-coded credentials in its source code, or when credentials are hardcoded in the deployment scripts for a microservice-based application, e.g., as environment variables passing secrets in a Dockerfile or a Docker Compose file [28,42]. Microservices are indeed likely have secrets to be used for communicating with authorization servers and other services. These secrets might be an API key, a client secret, or credentials for basic authentication [64]. The authors of eight out of the 58 selected studies clearly state that development teams should never store sensitive keys and other information in environment variables. In the latter case, the Confidentiality and Integrity of secrets may get violated, as they could be accidentally exposed, e.g., since exception handlers may grab and send the corresponding information to a logging platform. In addition, since child processes duplicate the parent's environment on startup, child processes may be another source of exposure of secrets in application logs, or they may be the reason why secrets could be unintentionally accessed by other services. In all such cases, we would end up with Confidentiality and Integrity leaks [36,67].
The authors of the 9 studies describing the potential security leaks due to Hardcoded Secrets all agree on saying that development teams can mitigate the effects of this smell if they Encrypt Secrets at Rest. This would indeed help achieving that only authorized resources have access to secrets. In doing so, development teams should also adopt the following best practices: they should never store credentials alongside applications [28] or in the repositories used to host their source code [63], nor they should exploit environment variables to pass secrets to applications [36].

Non-Secured Service-to-Service Communications
This smell occurs whenever two microservices in an application interact without enacting a secure communication [44,73]. As microservice-based applications are highly distributed, communication interfaces and channels proliferate, hence increasing the overall application attack surface. Each API exposed by each microservice indeed constitutes a potential attack vector that could be exploited by a malicious intruder, as it does each communication channel between any two microservices [35]. Microservices often need to communicate with each other to perform their business functions, and -if the communication channel is not secured-the data transferred can be exposed to man-in-themiddle, eavesdropping, and tampering attacks. This could not only result in Confidentiality issues for service-to-service communications, as it could also break their Integrity and authenticity, e.g., intruders could intercept the communication between two microservices and change the data in transit to their advantage [13,73].
The authors of the 32 studies describing the Non-Secured Service to Service Communications all agree on saying that this smell can be mitigated with the Use of Mutual Transport Layer Security. Mutual TLS [70] is indeed a widely-accepted solution to secure service-to-service communications, which enables encrypting the data in transit and ensuring its integrity and confidentiality. This is going to protect the microservice-based application context from man-in-the-middle, eavesdropping, and tampering attacks providing a bidirectional encryption channel. In addition, when Mutual TLS is used to secure communications between two microservices, each microservice can legitimately identify the microservice it is talking to, which means that microservices can authenticate each other [30,73]. Hence, whereas there exist other solutions for encrypting data in transit and ensuring its integrity, Mutual TLS is suggested by experienced practitioners as it also helps mitigating the Unauthenticated traffic smell (as we will discuss next).

Unauthenticated Traffic
The Unauthenticated Traffic smell occurs in a microservice-based application not only when there are unauthenticated API requests coming from external systems, but also when there are unauthenticated requests between the microservices of the application themselves [1,5]. To ensure Authenticity in microservice-based applications, it is critical to ensure that each microservice can authenticate each other, especially when the interactions are due to some user transactions and a microservice is passing the logged-in user context to the another microservice. The problem here is that no information is typically shared among microservices, and the user context must be passed explicitly from one microservice to another. The challenge is hence to build trust between two interacting microservices, in such a way that the receiving microservice can accept the user context passed from the calling one [73]. Therefore, a way is needed to verify that the user context (and, more generally, the data) passed between microservices has not been modified. If the traffic is not authenticated, there is actually no warranty that this is the case, and microservices are exposed to security attacks that may result in, e.g., tampering with data, denial of service, or elevation of privileges [54].
The Unauthenticated Traffic smells is discussed in 14 of the selected studies, whose authors highlight the refactorings to be enacted to mitigate this smell are to Use Mutual TLS and to Use OpenID Connect. As we already discussed how Mutual TLS [70] enables authentication between any two interacting services, we hereafter focus on the use of OpenID Connect. OpenID Connect is the most used mechanism to manage user authentication. It is based on the use of an ID token, typically a JSON Web Token that contains authenticated user information, including user claims and other relevant attributes [73]. The user ID token enables microservices to verify the user identity based on the authentication performed by an authorization server, as well as to obtain basic profile information about the end-user in an interoperable and REST-like manner. OpenID Connect hence provides a distributed identity mechanism for traffic authentication, which is also recognized to be easy to use, self-contained, and easy to replicate [15].

Multiple User Authentication
The Multiple User Authentication smell occurs when a microservice-based application provides multiple access points to handle user authentication [13]. Each access point constitutes a potential attack vector that can be exploited by an intruder to authenticate as an end-user, and having multiple access points hence result in increasing the attack surface to violate Authenticity in a microservice-based application [35]. The use of multiple access points for user authentication also results in maintainability and usability issues, since user login is to be developed, maintained, and used in multiple parts of the application [44].
The Multiple User Authentication smell is discussed in 21 of the selected studie, whose authors point out that development teams can mitigate the effects of this smell if they Use a Single Sign-On. The single sign-on approach suggests having a single entry point to handle user authentication and to enforce security for all the user requests entering the microservice-based application [35]. This approach facilitates log storage and auditing tasks [50], allowing the detection of abnormal situations that may occur. Single sign-on can actually be achieved if (i) we Add an API Gateway acting as a single entry point to the application, if not already there, and if (ii) we Use OpenID Connect to share the user context among the microservices. Both refactorings not only help implementing the single sign-on to mitigate the effects of the Multiple User Authentication smell, but also contribute mitigating the effects of other smells. Indeed, we already discussed how the use of an API gateway helps mitigating the Publicly Accessible Microservices smell, as well as how OpenID Connect enables mitigating the effects of the Unauthenticated Traffic smell (in Sections 3.2 and 3.8, respectively).

Centralized Authorization
In a microservice-based application, authorization can be enforced at the "edge" of the application (e.g., with the API gateway), by each microservice of the application, or both. The Centralized Authorization smell occurs when the microservice-based application only handles authorization centrally, typically at the edge, while it does not enact any fine-grained authorization control at the microservices-level. Such a kind of centralized authorization diminishes the advantages of having a distributed solution, such as that given by microservices, and it reduces performances and efficiency, since the central authorization point tends to become a bottleneck [28,73]. A Centralized Authorization may also result in violating Authenticity in microservice-based applications. For instance, when authorization is managed only at the edge, microservices are exposed to the so-called "confused deputy problem": they trust the gateway based on its mere identity, exposing the microservices in an application to misuse if they are compromised [49].
The Centralized Authorization smell is discussed in 19 out of the 58 selected studies. From such 19 studies, it emerges that development teams can refactor microservice-based application to mitigate the Single Authorization smell by enacting a decentralized authorization approach. They can indeed Use Decentralized Authorization by simply developing a token-based authorization mechanism. This is achieved by transmitting an access token together with each request to a microservice, and access to such microservice is granted to the caller only if a known and correct token is passed [66]. In this way, authorization can be enforced also at the microservices-level, as it gives each microservice more control to enforce its own access-control policies. It is generally recommended to have a dedicated service that acts as an authorization server, this provides three main benefits: decoupling and isolation in case the microservice-based application is compromised, separation of concerns, and an auditing point [50]. Among the 19 studies discussing the Use Decentralized Authorization refactoring, JSON Web Token (JWT) is the most used mechanism to implement such a refactoring. A JWT is a standard for safely passing claims or data attributed to a user within an environment [32], which ensures that a man in the middle cannot change its content because the issuer of the JWT actually signs it [73].

THREATS TO VALIDITY
Wohlin et al. [83] define the potential threats to the validity of studies in empirical software engineering, four of which also apply to our study. These are the threats to the external, internal, construct, and conclusions validity, which we discuss hereafter. External Validity. The external validity concerns the applicability of a set of results in a more general context [83]. Since the primary studies considered by our multivocal review were selected from a very large extent of online sources, the security smells and the corresponding refactorings may only be partly applicable to the broad area of disciplines and practices on microservices. This may hence result in threatening the external validity of our study.
To reinforce the external validity of our findings, we organised multiple feedback sessions during our analysis of the selected studies. The discussions held within and after the feedback sessions resulted in qualitative data, which we exploited to fine-tune both our research methods and the applicability of our findings. We also prepared a GitHub repository 1 storing the artifacts produced during our study, to make them publicly available to all who wish to deepen their understanding on the data we produced. We believe that this helps in making our results and observations more explicit and applicable in practice.
As for the external validity of our study, one may also consider our selection criteria as "too restrictive". However, such criteria enable focusing only on representative studies, viz., on studies that discuss at least a security smell or a corresponding refactoring. There is however a potential risk of having missed some relevant literature, as a study might not explicitly mention the security smells in our taxonomy (Figure 1). To mitigate this potential threat, we carefully checked both our selection criteria against each candidate study. We indeed checked whether a study was discussing the security issues connected to some security smell, and whether it was discussing the concrete changes to apply to a microservice-based application to mitigate the effect of such smell. This enabled us to select also those studies that were not explicitly referring to a smell or refactoring in our taxonomy, but rather reporting on the corresponding security issues or to-be-applied changes.
Finally, another potential threat to the external validity of our study is having missed relevant grey literature. Practitioners may indeed share knowledge by exploiting a different terminology than ours, e.g., a practitioner's blog post may discuss some security smells or refactorings, without explicitly mentioning the terms "smell" or "refactor". To mitigate this threat to validity, we included relevant synonyms in the search string, and we exploited the features natively supported by search engines, such as including related terms in string-based searches.
Construct and Internal Validity. Wholin et al. [83] define the internal validity of studies as concerning the method employed to study and analyse data, therein included the potential types of bias involved. They instead define the construct validity as the generalisability of the constructs under study.
To mitigate the potential threats to the construct and internal validity of our study, we reduced biases by triangulation and inter-rater reliability assessment trials. More precisely, we adopted thematic coding [3] to obtain the findings discussed in Section 3. The selected studies were subject to annotation and labelling with the goal of identifying the security smells and refactoring emerging from the analysed text. This process of analysis was executed in parallel over two 50% splits of the selected studies, to ensure avoidance of observer bias. The coders of the two splits (viz., the first two authors of this study) were then inverted and an inter-rater evaluation was enacted between the two emerging lists of security smells and refactorings. To evaluate inter-rater reliability, we adopted the Krippendorff K cofficient, which measures the agreement between two ordered lists of codes applied as part of content analysis [37]. We applied the K coefficient to measure the agreement among the emerging lists of security smells and of their corresponding refactorings by the two independent observers who individually coded 100% of the selected studies. The result of applying K to measure the agreement between the two emerging lists amounted to 89.1% agreement, above the typical reference score of 80%. The other two authors of this study were then involved in cross-checking the coding, without any prior knowledge on the coding itself, to further mitigate potential biases.
In addition, the taxonomy organising the emerging lists of smells underwent various iterations among all the authors of this study to further avoid bias by triangulation. The same process was applied to the actual classification of the selected studies and to the results of the analysis.
Conclusions Validity. The conclusions validity is defined by Wohlin et al. [83] as concerning the degree to which the conclusions of a study are reasonably based on the available data.
To mitigate potential threats to the conclusions validity of our study, we exploited the above described inter-rater reliability assessment to limit potential biases in our observations and interpretations. Additionally, the observations and conclusions discussed in this paper were drawn independently by the authors of this paper. They were then discussed and double-checked against the selected studies in two joint discussion sessions.

RELATED WORK
Various secondary studies analyse and classify the state of the art and practice on microservices. For instance, Pahl and Jamshidi [56] elicit potential research directions on microservices, after discussing agreed and emerging concerns on microservices and positioning microservices with respect to existing cloud and container technologies. Taibi et al. [79] instead report on common architectural patterns for microservices, by discussing the advantages, disadvantages, and lessons learned of each pattern. However, neither Pahl and Jamshidi [56] nor Taibi et al. [79] provide an overview on the smells possibly resulting in security issues in microservice-based applications, nor on the ways to mitigate their effects of such smells.
Other noteworthy examples are the systematic grey literature review by Soldani et al. [76] and the industrial surveys by Di Francesco et al. [14] and Ghofrani and Lübke [26], which all provide an overview on the state of practice on microservices. Soldani et al. [76] identify the technical and operational advantages and disadvantages of microservices, therein included the difficulties in securing microservice-based applications. Di Francesco et al. [14] and Ghofrani and Lübke [26] instead illustrate the results of surveys they conducted with practitioners daily working with microservices, also resulting in distilling the advantages and disadvantages of microservices. The studies by Soldani et al. [76], Di Francesco et al. [14], and Ghofrani and Lübke [26] differ from ours in their objective: they report on challenges and advantages of microservices, whereas we focus on distilling the smells that may possibly result in security issues in microservices, as well as on how to mitigate their effects.
In this perspective, the industrial survey reported by Taibi and Lenarduzzi [78] is a step closer to ours, as they first explicitly defined 11 microservice-specific bad smells. The smells defined by Taibi and Lenarduzzi [78] span from the design of microservice-based application to their actual development, and each smell is equipped with the best practices enabling to avoid incurring in such smell. Our results complement those by Taibi and Lenarduzzi [78], as none of the smells they define is about securing microservices. We instead precisely distill the refactorings that enable mitigating the effects of well-known security smells in microservice-based applications.
Similar considerations apply to the studies by Bogner et al. [6], Carrasco et al. [11], and Neri et al. [51], which all distill architectural smells for microservices. Bogner et al. [6] present a systematic literature review identifying and documenting architectural smells in SOA-based architectural styles, including microservices. Although the main focus of their review is on the broader SOA, several smells apply also to microservices. Carrasco et al. [11] and Neri et al. [51] instead explicitly focus on microservices, with two multivocal reviews distilling architectural smells for microservices as well as architectural refactorings enabling to resolve such smells. It is however worth noting that the focus of Bogner et al. [6], Carrasco et al. [11], and Neri et al. [51] is on ensuring that the architecture of microservice-based applications complies with the design principles defining microservices themselves. We hence complement the results of their studies, as we focus on another architectural aspect than complying with microservices' design principles, viz., securing microservice-based applications.
Finally, it is worth relating our study with the multivocal literature review by Pereira-Vale et al. [58], and with the grey literature review by Mao et al. [43], even if focused on DevOps rather than on microservices. Pereira-Vale et al. [58] report the state of art and practice of the security solutions that have been proposed for microservice-based systems, and they identified the most used ones. Mao et al. [43] instead report on the state of practice of DevSecOps, by first overviewing the currently existing risks in classical DevOps practices, and by then illustrating the best practices in DevSecOps and how they enable addressing the security risks of DevOps. The reviews by Pereira-Vale et al. [58] and by Mao et al. [43] differs from ours because they focus on the solutions proposed to support securing microservices, whereas we focus on distilling smells that may result in security issues in microservices. At the same time, the results in their reviews and ours complement each other, since, e.g., the security solutions they review can be used to implement the refactorings we describe.
In summary, to the best of our knowledge, there is currently no study classifying the smells that can possibly result in security issues for microservice-based applications, nor eliciting the refactorings that enable mitigating their effects. The latter is precisely the scope of our study, which we have presented in this paper.

CONCLUSIONS
We presented the results of a multivocal review focused on identifying the smells denoting possible security violations in microservice-based applications, and on the refactorings enabling to mitigate the effects of such smells. More precisely, we presented a taxonomy organising ten security smells and ten refactorings. The taxonomy associates each smell with the ISO/IEC 25010 [31] security properties it can violate, and with the refactorings that should all be applied to mitigate its effects. We also provided an overview of the actual recognition of each smell in the selected literature, we discussed the effects of such smells in detail, and we showed how each corresponding refactoring enables mitigating their effects.
The results of our study can be of help to both researchers and practitioners interested in microservices. Our study indeed complements other existing studies on smells and refactorings for microservices, e.g., Carrasco et al. [11] and Neri et al. [51], by covering the security aspects of microservice-based applications. This can have a pragmatic value for practitioners, who can exploit the results of our study in their daily work on securing microservice-based applications. It can also serve as a starting point for researchers wishing to study new solutions for securing microservices or to establish future research directions.
For future work, we plan to exploit the results of our study to develop an enhanced support for mitigating security smells in microservice-based applications. For instance, we plan to extend existing languages and tools supporting the design of microservice-based applications (e.g., TOSCA and Freshener [8], or that by Pigazzini et al [61]) to enable detecting security smells automatically, as well as to automatically recommend the refactorings that should be enacted to mitigate the effects of identified security smells. We also plan to relate our work to the technical debt one would experience in microservice-based applications, if security smells would appear therein.