473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 473,385 developers and data experts.

Securing a Database in Access

Rabbit
12,516 Expert Mod 8TB
INTRODUCTION
There has been considerable interest in the forum regarding Access and security. This is a primer on that topic.

First off, if you have a need for security, don't do it in Access. Security should always be implemented on the server side. The reason being that you should always keep the security files away from everyone except those that need them to implement the security. The problem with Access is that it is both the server and the client. This only holds true when using Access as the front end and the back end. You could use Access as a back end and a web server as a front end or vice versa, in which case you have separated the security from the clients.

Now, having said not to do it. Here's what you need to be aware of if you absolutely must use Access for both the front end and the back end.

Note About the Attachment
I have attached a sample implementation of some of the concepts in this primer. So that you can see how it's set up, some of the database had to remain unsecure.

The code is insecure so, ideally, you would want to create a compiled version of the database that the users will have access to.

Also, you should split out the stuff relating to account info into a separate, read-only database that a small group of people would have access to. Because of this, all password requests would have to go through a central point.

You will notice that I used a master password to encrypt the data. This is for flexibility. While it is more insecure to use a master password, it is necessary for functionality. If data was encrypted using the user password, you would lose data if the user forgets their password.

Despite any precautions you may take regarding the data, because Access is being used as the front end and the back end, a user could, in theory, decompile the compiled version of the database and find the master password. If this is not an acceptable risk, you must not use Access.

SECURING CODE
To secure code, you can do any number of the following:
  • Lock the VBA project
  • Create a compiled version of the database
  • Encrypt the database

Each option has different weaknesses you will need to be aware of.

If you lock the VBA project, a user can not view the code unless they enter a password. However, they can view the database file using another editor, such as Notepad. In this state, the code is in a semi-compiled format and strings are still readable. They will not be able to edit the file though; If they try, Access will lock out the database. I suspect that Access uses a hash of the last modified time to keep track of whether someone tried to access it outside of the database.

With enough knowledge, a person could decompile the code, or find the string you're using as password. With even more knowledge about the file format, they could find the hash that Access uses to track the last modified date, modify the code, and reconstruct the hash so Access would never know it was modified.

If you use this method, keep a backup database somewhere secure because if someone tries to modify the database outside of Access, and you have only the one copy, everyone will get locked out.

If you create a compiled version of the database, the code will be editable, but unreadable. However, it is possible for a person to decompile the code. As with the prior method, you should keep a copy of the database in case you need to edit the code.

If you encrypt the database, the code and the data will be unreadable. However, the people using the database will need the password. And if they have the password, then they can read everything. And if they were so willing, could save an unencrypted version of the database.

Those are your three options to securing code. You can use one, two, or all of the options.

SECURING DATA
Usually, if there is a need to secure data, it is because there is some information that only some people need to see and others should never see.

In Access 2003, there was the option of creating a security workgroup file with user accounts and passwords. The problem with this is that the users needed to be able to read the workgroup file for the security to work. And if you knew enough about the file format, you could read, change, or delete passwords.

In Access 2007, they did away with user level security. So if you needed it, you had to develop it in Access 2003, or try to implement it yourself in code.

Since user level security is needed when some information should not be seen by other people, this poses a big problem for Access. Because no matter what you do, the users have direct access to the data. The only thing you can do is to encrypt all the data that needs to remain secure. That way, even if the user can see it, they can't read it unless they have the password to decrypt it.

User Level Security
When using Access as both the front end and the back end and you have a need to secure data, you need some sort of user level security. This consists of storing account logins and passwords, keeping this secure, and encrypting the data that is confidential.

Storing Account Info and Passwords
This is the most insecure part of trying to secure data in an Access database. First of all, you can't just store the password in the table since the user can read it. So what you need to do at a minimum is to run the password through a cryptographic hash algorithm.

But even if you stored the hash, the user can see which hash belongs to which account. They could just delete the hash or overwrite it. So you need a way to obscure the relationship between the hash and the account. I recommend having a second account table that stores the account ID as a hash or as encrypted data. This way, they would have to hash or encrypt the account ID they're trying to find before they would be able to modify password data.

There are a few ways of handling the obsfucation of the account ID, each with its own drawbacks. You could:
  1. Hash the account ID
  2. Encrypt the account ID with the user's password
  3. Encrypt the account ID with a master password
If you choose 1, the user can hash the account ID they're trying to find so it's not much security. If you choose 2, you lose the ability to recover information if the user forgets their password. If you choose 3, you would have to code in the master password into the VBA coding.

However, the biggest security hole is that there's nothing to stop someone from deleting the table and recreating it with their own passwords. A way around this is to put the password data in a read-only file/database. But the drawback to this is that the user loses the ability to change their own password.

Here is a link to the SHA2 256-bit cryptographic hash algorithm.
http://bytes.com/topic/access/insigh...pt#post3643816

Encrypting Confidential Data
Since the user has direct access to the data, you must obfuscate the confidential data by encrypting it and decrypting it only when needed and the user is authorized.

There are two ways of handling the encryption of the data, each with its own drawbacks. You could:
  1. Encrypt the data with the user's password
  2. Encrypt the data with a master password
If you choose 1, you lose the ability to recover information if the user forgets their password. If you choose 2, you would have to code in the master password into the VBA coding.

There are many algorithms available that you can implement. Here are links to two algorithms that have VBA code. I recommend the second one because it is more secure and obscures the length of the data.
RC4 Stream Cipher
Advanced Encryption Standard
Attached Files
File Type: zip Security.zip (188.6 KB, 834 views)
Jan 24 '11 #1
1 9016
Rabbit
12,516 Expert Mod 8TB
Attached a sample implementation to the original post.

Additional note about the attachment: I forgot to include the user account information I used.
User1 - password1
Admin2 - password2
Jan 25 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Limey | last post by:
Hi All, I want to write an application that will talk to a RDBMS. The application needs to be platform neutral from both an operating system and database backend point of view. I have...
49
by: Relaxin | last post by:
It is just me or has MS created some of the worst ways to access and display data? You can use a DataSet, but if you want to sort or filter the data to must use a DataView which is created from...
4
by: Shawn H. Mesiatowsky | last post by:
I have a strange problem here. I have my development computer with IIS installed, and we have a SQL server as well on a windows 2000 server. both are members of a domain. I have restricted access...
4
by: Val P | last post by:
How does everyone design the database access layer in an asp.net application? Two options that come to mind is: 1. create a database class and instanciate it as needed, local to a function or...
2
by: williamphenryjr | last post by:
This is a long post. If you have answers I'm ready. If you have web links, that'd be great too. I'm a Junior/Senior in Computer Science at Washington State University, so you can make some...
5
by: Macca | last post by:
Hi, I have a multithreaded app which now needs database storage. I am in the process of designing my Data Access Layer but and was wondering what issues I should look for for in regards to a...
4
by: Stephen Poley | last post by:
Whenever anyone has a question about securing an Access database he/she is usually referred (unsurprisingly) to the Security FAQ. This is however incomplete/unclear with respect to databases with a...
7
by: =?Utf-8?B?Um9nZWxpbw==?= | last post by:
hey, I have 2 threads, th and th2, both of them run a method. each of these 2 methods requires database access. sometimes I get an error, that database requires an open connection, and that...
4
by: mlmn | last post by:
I bought an IBM USB Fingerprint reader. I want to use it to authenticate a user for database access. When some one tries to access a database, his ID should be provided and then his fingerprint...
0
Kosal
by: Kosal | last post by:
Hi Please help me to create AdRotator using Database Access in ASP.NET if everyone can because I don't know how to create table AdList in access and how to contect to access and get data from...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.