Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

2021 IEEE 30th International Conference on Enabling Technologies: Infrastructure for Collaborative Enterprises

(WETICE)
2021 IEEE 30th International Conference on Enabling Technologies: Infrastructure for Collaborative Enterprises (WETICE) | 978-1-6654-2789-0/21/$31.00 ©2021 IEEE | DOI: 10.1109/WETICE53228.2021.00020

Automatic Generation of Access Control for


Permissionless Blockchains: Ethereum Use Case
Insaf Achour Hanen IDOUDI Samiha Ayed
National School of Computer Sciences National School of Computer Sciences University of Technology of Troyes
University of Manouba University of Manouba LIST3N-ERA, Troyes, France
Manouba, Tunisia Manouba, Tunisia samiha.ayed@utt.fr
insaf.achour@ensi-uma.tn hanen.idoudi@ensi-uma.tn

Abstract—Access control in Blockchain context is a crucial In fact, the RBAC [3] model use roles to decide which users
step. During this process it is important to verify that users have are privileged to reach certain resources. Users can be users
the right roles to get access to the protected resources. To model having accounts in Ethereum Blockchain or they can also be
its access control, the Ethereum Blockchain is based on RBAC contracts. A secure contract must respond to this requirement:
model. The whole process is written in a smart Contract imported
from The OpenZepplin Library [1]. However, the automatic gen- only contracts and users with a privileged role can get access
eration of the access control policy still missing. This automation to the verified contract.
can widely enhance and simplify the implementation of access To build a correct and a secure smart contract we must
control for developers of blockchain based applications. In this do it from the beginning and from the design stage. The
paper, we propose a new model for automatically generating the integration of Model Driven Engineering in smart contracts de-
access control smart contract. Our approach is based on the
Model Driven Engineering (MDE). velopment has proven good results [4]. The approach consists
Index Terms—Smart Contract, Model Driven Engineering, in generating smart contracts automatically. Thus, it reduces
Blockchain, Access Control, Ethereum, Solidity. the programming language understanding complexity. It also
allows the reuse of code and models through giving better
I. I NTRODUCTION clarity of a system then a code. In this paper, our focus is made
on the Ethereum blockchain technology. The actual smart
B LOCKCHAIN was introduced by Satoshi Nakamoto in
2008 [2] to overcome the lack of trust in banks caused
by the financial crisis. So he presented the new cryptocurrency
contracts generation used within this technology is based on
the OpenZepplin library. The generation of the smart contracts
Bitcoin. It allows the transfer of financial transactions with- using this library is not including the generation of the access
out the need of third-party. Blockchain guarantees security, control policy that may be included within a smart contract.
transparency and immutability of transactions. To complete this aspect, we propose a MDE approach to
In fact, Blockchain is used to store a verified and time automatically generate access control within the Ethereum
stumped transactions between participants in a peer-to-peer blockchain smart contracts. The contributions of this work are
network without going through a trusted third-party. as follows:
This technology is based on four mechanisms: (1) the • We propose a model for the access control in Ethereum.
cryptography, (2) the distributed and decentralized ledger, (3) • We create a profile that includes the concepts of RBAC
the consensus and (4) the smart contracts. In this paper we model and the Solidity syntax.
are interested in the smart contract mechanism, that appears • We implement a proof of concept of Solidity smart
in 2011 to improve blockchain technology. The smart contract contract generation.
defines the business process that includes the requirements, The paper is organized in four sections. The related works
conditions and events to execute a transaction. Smart contracts dealing with smart contract engineering and access control in
can be created to manage the Business logic, the asset storage Ethereum Blockchain are discussed in the section II. In section
and to grant more security for the transferred transactions. III, we present our model as well as the implementation of
Security includes many properties such as privacy, integrity, our approach. Section IV concludes the paper and presents
authentication, authorization, etc. the perspectives of our work.
In our work, we are interested in the access control property.
The access control is the mechanism that determines who has II. R ELATED WORK
permission to get access to the resources or the services in
A. Smart contract engineering
a system. In the literature, many access control models exist.
However, in the Blockchain context the most used models are A smart contract is a computer program that executes
RBAC (Role Based Access Control) and ABAC (Attribute- transactions automatically in a Blockchain. Clack and al [5]
based access control). The Ethereum Blockchain is based on define a smart contract as "an automatable and enforceable
the RBAC model. agreement. Automatable by computer, although some parts

2641-8169/21/$31.00 ©2021 IEEE 45


DOI 10.1109/WETICE53228.2021.00020

zed licensed use limited to: MINISTERE DE L'ENSEIGNEMENT SUPERIEUR ET DE LA RECHERCHE SCIENTIFIQUE. Downloaded on April 16,2022 at 13:23:55 UTC from IEEE Xplore. Restriction
may require human input and control. Enforceable either by (model driven architecture) guidelines. There are, also, other
legal enforcement of rights and obligations or via tamper-proof approaches that used finite state machines [11]-[12]. In [11]
execution of computer code". authors presented an MDA for the solidity smart contracts.
As any software, smart contract has a development life cy- For the CIM level, they used the agent-based approach with
cle. In [6] authors presented four steps: creation, deployment, the grammar of institutions. For the PIM level, the state
execution and completion. that we summarize as follows: machine approach was applied. Finally, for the PSM level, they
• Creation: to create a smart contract, the involved parties transformed the Finite state machine (FSM) into a Solidity
must define the clauses of the contract by negotiating smart contract skeleton. Authors in [12] have created a tool
the obligations, rights, prohibition and agreement. Then, for generating Solidity smart contract from the state machine
computer developers implement the contract with a com- models.
puter language and validate it. So this step is an iterative Discussion: We have noticed that most of the works were
procedure starting by designing the architecture, coding focusing on the Solidity smart contract. This choice is mainly
and testing. due to the Ethereum blockchain that can support public, private
• Deployment: during this phase, the smart contract is de- and consortium deployment. Another finding is that code
ployed in the Blockchain network and cannot be altered, generation is not totally automatic in most of works so we
so any correction requires the generation of a new smart need the intervention of smart contract developer to implement
contract. some logic methods. The other finding is that the integration
• Execution: a transaction calls the execution of a smart of MDE is designed to handle Business logic and/or asset
contract when all its conditions are satisfied. After that, storage and doesn’t focus on security aspects such as privacy,
miners should validate the transaction. integrity and access control. Considering these findings we
• Completion: after the execution and the validation of a propose, in this paper, to model the access control in Ethereum
transaction, assets are transferred to their new owners. Blockchain.
During this step, the states of the parties are updated and
the contract comes to its end. B. Access Control in Ethereum
The development of a smart contract is a complex task,
especially that smart contracts cannot be altered after the Ethereum is a public platform, it was created By Vita-
deployment phase. So the code source of the smart contract lik Buterin [13] to build applications and smart contracts.
must be correct from the design. In fact many works proposed This platform supports many programming languages such as
the integration of Model Driven Engineering (MDE) for the JavaScript, Python and Solidity. These languages are running
generation of smart contracts. The Model Driven Architecture through The Ethereum Virtual Machine (EVM).
(MDA) is composed of four levels that are as follows: CIM The Ethereum bockchain is based on the proof of stake
(Computational Independent Model), PIM (Platform Indepen- consensus and its actors are EOA (Externally Owned Ac-
dent model), PSM (Platform Specific Model) and the Code count), contract and miners. The EOA interacts with the
generation [7]. Blockchain via sending a message to another account on the
In literature, three different approaches exist: works based network which forms the transaction that will be stored in the
on BPMN, others on UML modeling and some works based a Blockchain.
the finite state machine. In this paper, we discuss, as example, The transaction data are the signature of the sender, the
the most recent work from each category. address of the recipient, the transferred amount, the start Gas
The use of BPMN was proposed in many works [8]-[9]. and Gas price values as well as other data. The start Gas is
In [8], authors developed a tool named Lorikeet that allows the maximum of gas required to execute the code and the
the code generation of Solidity smart contracts. This tool Gas price is the amount that must be paid to perform the
is divided in three parts: the first one is the modeling step transaction.
which is split on modeling Business logic used BPMN 2.0 The access control in Ethereum Blockchain is based on
and modeling asset registry based on UML class diagram. three models developed by the OpenZepplin library [1]: (1)
The second part is the code generation where they trans- the "ownable" contract, (2) the "Role-Based Access Control"
late the BPMN and UML models into Smart contract, the contract and (3) the "AccessControlEnumerable" model. The
attributes and registry types become fields, the operations are Ownable contract is the basic form of access control where
translated to methods and the BPMN will be the instantiation the account of the contract owner is the administrator and
of these methods and their logic implementation. The last he is the only owner of the contract. The Role-Based Access
part is addressed to the Blockchain interactions which are Control is designed for contracts requiring different levels of
communication, deployment and compilation. authorization. Then, this contract is based on RBAC where it
Other approaches were based on UML methodology [10]- defines multiple roles with a set of permissions and it also
[11]. In [10], the authors proposed a methodology based implements rules for how accounts can be granted or revoked
on an UML modeling to create smart contracts for het- to/from a role. The last model called " AccessControlEnumer-
erogeneous blockchains, using Resources-Event-Agent (REA) able" is added to the second contract when enumerability is
ontology, commitment-based smart contracts and the MDA required.

46

zed licensed use limited to: MINISTERE DE L'ENSEIGNEMENT SUPERIEUR ET DE LA RECHERCHE SCIENTIFIQUE. Downloaded on April 16,2022 at 13:23:55 UTC from IEEE Xplore. Restriction
In the literature, apart from Openzepplin library, [14] and Discussion: For our work, we choose to model the OpenZep-
[15] have also implemented the access control in the Ethereum plin implementation. The first argument of our choice is that
Blockchain. The implementation in [14] is called RBAC-SC. OpenZepplin implementation is considered as a standard for
The aim of this work is to realize the RBAC mechanism and Ethereum and compared to RBAC-SC and Smart policy, it is
to verify the user role assignments. Therefore, the authors pro- performed totally on the blockchain. Moreover, the process of
posed a model composed of two main parts: a smart contract the permissions and roles allocation is transparent and there
and a challenge-response protocol. The smart contract (SC) is no risk of malicious handling. Another motivation for our
is used for the creation of the user-role assignments, which choice is that OpenZepplin contracts are more flexible since
are then published on the blockchain. The challenge-response they provide three types of access control according to the
protocol is used for the authentication of the ownership of policy of the access control.
roles and the verification of the user role assignment.
The RBAC-SC implements the following functions: III. AC ENGINEERING FOR E THEREUM
• addUser(u.EOA, u.role, u.notes) and removeUser(u.EOA) A. AC Modeling using SecureUML
that can only be executed by the SC owner or creator. There are two extensions to model security concepts with
• addEndorsee(eu.EOA, eu.notes) function that can only be UML: SecureUML and UMLsec. In fact, SecureUML [16]
executed by a user who has already been added in the SC. is an extension of the class diagram with stereotypes, tagged
• removeEndorsee(eu.EOA) function that can only be exe- values and authentication constraint written in OCL. UMLsec
cuted by a user to remove an endorser from the SC. [17] is a UML profile using stereotypes, tagged and authenti-
• changeStatus() function can only be executed by the SC cation constraints without identifying the constraint language.
owner or creator to deactivate the SC. The two extensions are designed for the RBAC model. Figure
The challenge-response protocol is triggered when a user 1 presents the elements of the RBAC model. Users can be
requests a service corresponding to his role. The protocol has persons or systems, roles are the functions in an organisation,
five steps: operations are the set of actions that can be performed on the
protected objects or resources and permissions are the access
• Declaration: in this step, they define the user who is the
rules of operations to objects. In the RBAC model there are
EOA with a role corresponding to a service issued in the
two relationships. The first one is the user assignment that
first part.
presents the mapping between users and roles. The second
• Information Check: the service provider checks the infor-
one is the permission assignment relationship that defines the
mation of the corresponding user dealing about his role
set of privileges allocated to a role.
and checking if he is the owner of the EOA.
• Challenge: The service provider chooses an arbitrary data
and requests the user to sign in using this data.
• Response: the user signs with EOA and the private key.
• Response Verification: if the verification is successful,
then the service will be provided.
The second Implementation of the access control in
Ethereum is Smart Policies [15]. This work is based on the Fig. 1. RBAC Model[3]
ABAC model. The authors propose to write the policies on
XACML and to translate them into Solidity smart contract. The difference between SecureUML and UMLsec is in the
The components of XACML standard such as the Policy stereotype signification. SecureUML is a specific modeling
Enforcement Point (PEP), the Policy Administration Point language of the RBAC model. It defines stereotypes, such as
(PAP), the Attribute Managers (AMs), the Policy Information «user» , «role», «permission», «actiontype», «secureresource».
Points (PIPs) and the Policy Decision Point (PDP) are defined This means that SecureUML extends mainly the profile of the
on top of the blockchain technology. The Context handler UML class diagrams. UMLsec extends the whole UML profile
(CH) is split on the off chain component and the blockchain by stereotypes that are applied at multiple UML diagrams. The
protocol. This approach is divided in two steps: «rbac» stereotype is the only extension applied in the activity
• New policy creation: during this step, the resource owner diagram.
writes a XACML policy and sends it to the PAP to be For our work, we have chosen the SecureUML because in
stored in the Blockchain. Then the PAP translates the term of quality measures, SecureUML presents better quality
XACML policy into a smart contract called "the SMART than UMLsec according to the study presented in [18]. In fact,
POLICY". After that, the initial CH deploys the contract authors gave a comparative study between the two models and
in the Blockchain and will be stored once it is accepted. measured the semantic quality, the syntactic quality and the
• Access request time: after the creation of the contract pragmatic quality. For example, the percentage of covering the
"Smart Policy", the blockchain Access Control service RBAC domain is 100% and the percentage of security related
will respond to the access requests. statement is 100% in SecureUML.

47

zed licensed use limited to: MINISTERE DE L'ENSEIGNEMENT SUPERIEUR ET DE LA RECHERCHE SCIENTIFIQUE. Downloaded on April 16,2022 at 13:23:55 UTC from IEEE Xplore. Restriction
Our proposed model is based on SecureUML concepts UML modeling part, we used Papyrus Editor [21] and we built
to model the "Role Based Access Control" contract from our profile named OZProfile that combine the SecureUML
OpenZepplin library. In fact, we extended the UML profile, Profile and the Solidity Profile. For the code generation part,
called UMLtoSolidity [19], with new stereotypes based on the we used the Acceleo code generator [22] to create a template
RBAC modeling using SecureUML. In figure 2, we present the that let the mapping between OZProfile stereotypes and the
stereotype extension mechanism added to the meta classes of solidity syntax.
the Solidity profile (highlighted in purple). To validate our model we give the example of an ERC20 to-
We divide our approach into three steps: (1) the policy ken [23] (fungible asset) contract modeled with our model. In
contract modeling, (2) the role allocation modeling and (3) the figure 3, we introduce the two packages. The first package
the Solidity code generation. We also propose to put the two is for policy which contains the Token as a contract, minter
first processes in the same smart contract to facilitate its mon- and burner as roles. The second package is the RoleAllocation
itoring. Then, we suggest to represent the policy and the role that models the allocation of roles to the user accounts.
allocation as packages. Therefore, for each creation of contract In figure 4 and 5 we expose the generated Smart contracts
policy, the package role allocation is imported automatically. that result from the mapping between SecureUML concepts
To do so, we suggest to combine the SecureUML model with and Solidity syntax. Figure 4 demonstrates the protected
the Solidity concepts. resource contract (MyToken) and figure 5 shows the access-
1) Policy contract modeling: in this package we build Control contract that corresponds to the role allocation.
a class diagram that contain roles, permissions and IV. C ONCLUSION
resources.
2) Role allocation modeling: this package is also based In this work, we presented a model for the "Role-Based
on class diagram. Actually, as defined in OpenZepplin Access Control" contract from OpenZepplin library. Our ap-
[1], each role has its administrator. An administrator can proach is divided into three steps: policy definition, role
grant and revoke roles to others accounts. There is a allocation and Solidity code generation based on the mapping
default administrator role who is the initial administrator between SecureUML stereotypes and Solidity syntax. Our
of all the roles. Thus, he can do the same tasks as role approach is designed to help developers without background
administrator and also he can set the role administrator. on OpenZepplin access control contracts to easily understand
3) Solidity code generation: in this step, we extend the it and to automatically generate it. The main advantage of our
syntax of Solidity with the SecureUML concepts. In the approach is the simple reuse of contract.
table 1 we give the combined concepts from SecureUML For future work, we will enrich our code generation to
and Solidity profiles and its representation in UML. produce more generated code and to support OCL. We also
plan to integrate a Solidity editor and compiler to check the
source code and to build a plugin of our generator. Another
TABLE I
M APPING BETWEEN S ECURE UML-UML-S OLIDITY future recommendation is to perform a set of tests on a
Blockchain simulator to compute the gas consumed by the
SecureUML UML Solidity
Object Class Contract
generated contracts.
User Class Account
Role Class Variable Byte32
Permission Class Association Function (call hasRole
function)
Operation Action in class Permission Function associated to role
Authorization OCL Permission Function body
constraint

The protected resource or the object in SecureUML is


the developed contract. Users in Ethereum, as mentioned
before, can be users accounts or contract accounts which are
represented by their address. The roles are represented as
a Byte32 variable in the contract. The operations, that are
the actions in the RBAC context, are modeled as operations
in the association class stereotyped as «Permission». The
authorization constraints are the body of the action function.

B. Code generation
For the validation and the evaluation of our approach, we
have developed a proof of concept implementation of an access
control model generated in Solidity code source. We have
implemented our model in Eclipse Environment [20]. For the

48

zed licensed use limited to: MINISTERE DE L'ENSEIGNEMENT SUPERIEUR ET DE LA RECHERCHE SCIENTIFIQUE. Downloaded on April 16,2022 at 13:23:55 UTC from IEEE Xplore. Restriction
Fig. 2. Stereotype extension mechanism

Fig. 3. ERC20 Model

Fig. 4. Generated Token smart contract

49

zed licensed use limited to: MINISTERE DE L'ENSEIGNEMENT SUPERIEUR ET DE LA RECHERCHE SCIENTIFIQUE. Downloaded on April 16,2022 at 13:23:55 UTC from IEEE Xplore. Restriction
Fig. 5. Generated RoleAllocation smart contract

R EFERENCES language for model-driven security. UML 2002 - The Unified Modeling
[1] https://github.com/openzeppelin/openzeppelin-contracts. Language: 5th International Conference, Dresden, Germany,, 2002.
[2] S. Nakamoto. Bitcoin: A peer-to-peer electronic cash system. White [17] J. Jürjens. Secure Systems Development with UML. 2004.
paper, 2008. [18] H. Lakk R. Matulevičius and M. Lepmets. An approach to assess and
[3] S. Gavrila D. Richard Kühn D. F. Ferraiolo, R. Sandhu and R. Chan- compare quality of security models. Computer Science and Information
dramouli. Proposed nist standard for role-based access bontrol. ACM Systems 2011 Volume 8, Issue 2, Pages: 447-476, 2011.
Transactions on Information and System Security (TISSEC), 4(3), 224– [19] https://github.com/urszeidler/uml2solidity .
274, 2001. [20] https://www.eclipse.org/ide/.
[4] A. Ponomarev and A. B. Tran. Model-driven engineering for [21] https://www.eclipse.org/papyrus/.
blockchain applications. Architecture for Blockchain Applications, [22] https://www.eclipse.org/acceleo/.
https://doi.org/10.1007/978-3-030-03035-38 , 2019. [23] https://docs.openzeppelin.com/contracts/3.x/erc20.
[5] B. VA C. CD and L. Braine. Smart contract templates: foun-
dations, design landscape and research directions. Available from:
https://arxiv.org/pdf/1608.00771.pdf, 2017.
[6] M. Alharby and A. V. Moorsel. Blockchain-based smart contracts:
A systematic mapping study. Fourth International Conference on
Computer Science and Information Technology (CSIT-2017), 2017.
[7] A. R. da Silva. Model-driven engineering: A survey supported by
the unified conceptual model. Elsevier Computer Languages, Systems
Structures Volume 43, October 2015, Pages 139-155, 2015.
[8] I. Weber H. O’Connor P. Rimba X. Xu Q. Lu, A. B. Tran, L. Zhu
M. Staples, and R. Jeffery. Integrated model-driven engineering of
blockchain applications for business processes and asset management.
Software: Practice and Experience, 2020.
[9] W.Ingo M. Staples A. B. Tran, X. Xu and P. Rimba1. Regerator:
a registry generator for blockchain. CAiSE’17, Forum Track (demo).
Essen, Germany: Springer:81-88., 2017.
[10] K.Boogaard. "a model-driven approach to smart contract development".
2018.
[11] A Mavridou. and A. Laszka. Designing secure ethereum smart contracts:
A finite state machine based approach. Financial Cryptography and
Data Security, 2018.
[12] Yakindu statechart tools. https://www.itemis. com/en/yakindu/state-
machine, Online.
[13] V. Buterin. A next-generation smart contract and decentralized
application platform. Ethereum White Paper. Available online at:
https://github.com/ethereum/wiki/wiki/White-Paper/, Accessed in 02-11-
2020.
[14] Y. Kaji J. P. Cruz and N. Yanai. Rbac-sc: Role-based access control using
smart contract. IEEE Access: Special section on research challenges and
opportunities in security and privacy of blockchain technologies, 2018.
[15] P. Mori D. Di Francesco Maesa and L. Ricci. Blockchain based access
control services.
[16] D. Basin T. Lodderstedt and J. Doser. Secureuml: A uml-based modeling

50

zed licensed use limited to: MINISTERE DE L'ENSEIGNEMENT SUPERIEUR ET DE LA RECHERCHE SCIENTIFIQUE. Downloaded on April 16,2022 at 13:23:55 UTC from IEEE Xplore. Restriction

You might also like