QStudio
Query kdb+ Servers and Chart Results.
Out of the box kdb provides severely limited authentication and access controls. It is up to the user to modify the default setup to satisfy these requirements when needed. We will consider typical security requirements and how we can implement them.
Kdb provides a number of command line options for restricting access, these include:
-U | Specify a username / password file that contains the list of permitted users and their passwords. |
---|---|
-u | Same as -U however further restricted that q process can not access files above it's current directory. |
-b | Connected clients cannot write to the database, for them it is read only. |
-T | Enforce a timeout in seconds on all client queries. |
Here we demonstrate protecting a kdb server using an md5 encrypted password file. Notice the client process cannot open a connection without specifying the correct username and password as set in our file.
Server |
Client |
When running with -u it also restricts what files can be accessed, which system commands can be run. However as demonstrated in the video, these can be worked around by a malicious user for example by overriding the timer .z.ts function to run the commands as console.
Server started with "q -u ../userpass.txt -p 5000". Then from client call:
The second feature kdb exposes for handling security are event handlers. You can override special functions to handle authentication and client calls. These would allow denying users access on an extremely customizable level. important event handlers include:
.z.pw | PassWord authentication. First arg is username symbol, second is password string. |
---|---|
.z.pg | Synchronous or Get call handler, x argument is the incoming message. |
.z.ps | Asynchronous or Set call handler, x argument is the incoming message. |
.z.po | Port Open, called when a new connection is made. |
.z.pc | Port Close, called when an existing connection is closed. |
Complete details on kdb event handlers and a video guide to using them are available on the IPC tutorial.
As you can see kdb provides extremely powerful hooks into their system to implement security but it is very much up to you to write that code.
Server |
Client |
Try tunning user-table.q as the server script, to see an example of having a user table to control access using .z.pw
Our example file restricted-querys.q allows running a server that restricts users to only running selected functions.
Server |
Client |
AAA is a common acronym in computer security that refers to:
In this tutorial we covered
The latest versions of kdb include new functionality useful for security:
Query kdb+ Servers and Chart Results.