Recently, the state is trying to transfer all state services to electronic format as much as possible. Address certificates are actively issued, and other certificates are issued through the e-government portal. You can even register marriage marry through the portal. In fact, very convenient. Of course there are minuses, mostly organizational. regulatory at the level of laws, at the level of implementation. But this is another question, the main thing is very good initiatives. It's all good, but the post is not about that.
Obviously, to use public services, you need to somehow confirm your identity. For this, once a long time ago, the use of electronic signature was fixed by law. The basic formulation of the use of EDS such - EDS equates to a handwritten signature. Many do not know, but for the transfer of EDS keys (hereinafter I will use the term - EDS keys. Everyone calls simply EDS, and in fact these are two pairs of keys - for authentication and signature). For the transfer to third parties even have some responsibility. It is obvious that many people do not care, do not understand all the seriousness.
In general, the theme of the post about NCALayer, the layer between the browser and EDS keys. Security is a vulnerable mechanism for using EDS.
Since the main implementation of a crypto-provider in Java and in the latest versions of browsers is not possible to use applets, the NUC has come up with an original solution for using EDS in browsers. This solution is called - NCALayer. NCALayer - an intermediary between the browser, cryptographic provider and EDS keys.
NCALayer is installed locally on the user's computer. NCALayer works as follows - a web server is opened on a specific port where different requests are sent.
Omitting all the details of the connection, we’ll consider two requests so far to get a general idea of how NCALayer works:
{ 'method': "browseKeyStore", 'args': ['PKCS12', 'P12', '/home/user'] }
After sending the request, on the machine where the NCALayer is located, a dialog box opens that offers to select the EDS key file.
Accordingly, after selecting the key, we get the following answer through the socket.
{"result":"/home/user/AUTH_RSA.p12","errorCode":"NONE"} {"errorCode":"NONE"}
Attention: when using NCALayer, you get the real path to the file on the client machine.
{ "method": "signXml", "args": [ 'PKCS12', '/home/user/AUTH_RSA.p12', '1874abcef234', '!!!', '<login><timeTicket>1517997213006</timeTicket></login>' ] }
I will not publish the answer, but it contains the signed part of the xml, which was in the request.
Again, get a password from the EDS keystore, falls on the shoulders of the site. That is, the site always knows where the user's keys and password are , otherwise it is impossible to work.
I will not go deep into technical details and implementation. I will describe how to do it.
Now, in order to exploit this vulnerability, it is necessary to understand how the entry mechanism for egov.kz works through EDS. To login to egov.kz, xml from egov.kz is signed by the user and transmitted to the server, where it is checked. If the signature is valid, then log in. From the NCALayer side, the login process consists of the following steps:
The portal requests the following data from NCALayer - loadSlotList (here you can answer with an error), getKeys, getSubjectDN, getNotBefore, getNotAfter, and signXml. If NCALayer correctly substitutes this data from another user, then accordingly we will successfully log in. Here it is very important to get only the subjectDN and xml for the signature from NCALayer.
Now how to access egov.kz from another person, the mechanism:
document.getElementById('xmlToSign').value
.Update:
Emulator NCALayer
An application that, without the knowledge of the user, in the background signs data
Source: https://habr.com/ru/post/348348/
All Articles