473,408 Members | 1,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Trying to fix bad login/security set up.

We have a home grown CMS in our organization that I decided to update at 5pm
only to find a gigantic security bug in it.

Here's the deal:

The original programmer created the security for the CMS. When a person logs
in, they're authenticated against the DB and then pertinent info regarding
their permission levels is saved into a cookie on their machine.

We then have a class/usercontrol that loads on every page of the CMS that
reads this data from the cookie to establish their security credentials.

Here's how it was originally written:

------------------------------------

Public Class SecureUsers

Public Shared su_strUser As String
Public Shared su_strEmail As String
Public Shared su_intDistrict As Integer
Public Shared su_intAdminLevel As Integer
Public Shared su_categories As String
Public Shared su_strDistrict As String

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
InitializeComponent()

If Not Request.Cookies("CMSUser") Is Nothing Then
su_strUser = Server.HtmlEncode(Request.Cookies("CMSUser")("su_s trUser"))
su_strDistrict =
Server.HtmlEncode(Request.Cookies("CMSUser")("su_s trDistrict"))
su_intDistrict =
Server.HtmlEncode(Request.Cookies("CMSUser")("su_i ntDistrict"))
su_strEmail = Server.HtmlEncode(Request.Cookies("CMSUser")("su_s trEmail"))
su_categories =
Server.HtmlEncode(Request.Cookies("CMSUser")("su_c ategories"))
su_intAdminLevel =
Server.HtmlEncode(Request.Cookies("CMSUser")("su_i ntAdminLevel"))
End If
End Sub

End Class

------------------------------------

Then, on every page of the CMS that loads the above control, we grab the
variables as needed such as:

username = secureusers.su_strUser

Now, you can probably see what is wrong with the above. The variabls were
all set to public SHARED--which means the variables were shared at the class
level rather than the instance of the class. As such, the data was being
cross-written from thread to thread. One person would log in, start editing,
another would log in, and then when the first person saved, the other
person's credentials were saved instead.

Since I'm not really an OOP expert, it took me a bit and then I realized I
needed to get rid of the SHARED modifier.

So, I did that, and now I'm trying to get the data by creating an instance
first:

Dim theSecureUser As New SecureUsers
username = theSecureUser.su_strUser

Now...THE PROBLEM: This just returns null values. No error, just no value.
WHY!?

Bigger question:

For now, I'm just trying to duct-tape the above for the weekend so that I
can go home. But come Monday, I'm going to have to start rewriting this.
What's the better way to handle it? Obviously, writing the credentials in
the cookie, itself, is dumb. Is it better to use session state? Another
method?

-Darrel
Feb 10 '07 #1
2 1233
Sorry if this is way off base... I don't normally program in VB.Net
and I'm not sure I understand correctly.

Short Answer: Replace "Page_Init" with a class constructor.

Long Answer:
If I understand what I'm reading correctly, it looks like you have
properly instantiated an instance of the SecureUsers class, but the
code that sets values in all of the public member variables at top
would never run. It's in a function called Page_Init... and there is
nothing that would call the Page_Init function (this doesn't appear to
be an asp.net page - just an ordinary class).

Solution: Create a default constructor that gets run when you
instantiate the SecureUsers class. Cut the code out of Page_Init and
put it in the constructor.

Hope that helps and I understood correctly.
Feb 10 '07 #2
Hope that helps and I understood correctly.

Thanks. It does.

This particular page is a usercontrol that is getting loaded with each page.
perhaps that's the issue?

I did go ahead and try to make a constructur (separate function) but when I
do that, it failes to 'see' the cookie. For some reason it can't read the
cookie from a contained function.

-Darrel
Feb 10 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: mo | last post by:
Sorry I can't be more specific, but.... I'd like to create a secure login from an ASP page to a specific SQL Server 2000 Db. Is there an accepted methodology for doing this? Are there any...
3
by: Rudi Groenewald | last post by:
Hi there... I use SQL server integrated security so when a user opens a database in access it prompts the username & password in a small popup box on connection, but I'd like to use my own...
5
by: paulp | last post by:
Greetings, I'm working on a CGI program that will run under MS IIS 5.0 and will browse folders on three other machines, building HTML pages that will provide links to these folders. ...
19
by: Siobhan | last post by:
Hi What is the recommended way to store a user's database credentials across the pages of a web application so that each time the database is accessed the system doesn't have to ask them for their...
1
by: Friends | last post by:
Hi I need to set security for row level but not based on Database user's login. It should be based on the user table login. For the particular user I need to allow only the particular records to...
7
by: Samuel Shulman | last post by:
Is there a method that will indicate the person who logged successfully is Logged and therefore allowed to browse freely other then using the...
1
by: kito | last post by:
Hi, I have a problem, when I want to access to my SQL Server Express database from my ASP.NET application. My workstation ID is KITOLAP-HP My username is user01 Now I built the following...
0
by: muder | last post by:
I have a standard Login ASP.NET 2.0 control on a login Page, a LoginName and LoginStatus controls on the member's page. once the user login successfully I am redirecting the user to Member.aspx...
6
by: Kat | last post by:
Every time I attempt to run a localhost website, it asks me for a login, as if I am not a user on the local machine. I am a user on the local machine, I am an admin on the local machine. I am not...
4
by: Brett | last post by:
I have an ASP.NET 2.0 application that uses Forms Authentication. The startup page contains just a login control, and the site works well on an IIS 6 web server. I am now setting the site up on...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.