473,385 Members | 1,769 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,385 software developers and data experts.

how to securely store a record index when editing a mysql record

hi everyone- my subject pretty much says it all- is there a secure way
to do this? the non-secure ways are, as i understand it, to populate
a listbox with indices as names, or maybe use a hidden control. is the
only secure way with sessions? i was also thinking about perhaps
creating a meta table that says who is editing which record right
now. any advice?

thanks,
dino

Mar 9 '07 #1
12 1767
dino d. wrote:
hi everyone- my subject pretty much says it all- is there a secure way
to do this? the non-secure ways are, as i understand it, to populate
a listbox with indices as names, or maybe use a hidden control. is the
only secure way with sessions? i was also thinking about perhaps
creating a meta table that says who is editing which record right
now. any advice?

thanks,
dino
Define "Editing a MySQL record".

What happens if the user brings up an edit form then shuts off the
computer, for instance?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Mar 10 '07 #2
i'm really mostly concerned about how to pass the record id of the
edited record on post without exposing the record ID to the html
source. thanks for any help.

dino
On Mar 9, 10:46 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
dino d. wrote:
hi everyone- my subject pretty much says it all- is there a secure way
to do this? the non-secure ways are, as i understand it, to populate
a listbox with indices as names, or maybe use a hidden control. is the
only secure way with sessions? i was also thinking about perhaps
creating a meta table that says who is editing which record right
now. any advice?
thanks,
dino

Define "Editing a MySQL record".

What happens if the user brings up an edit form then shuts off the
computer, for instance?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================

Mar 11 '07 #3
dino d. wrote:
i'm really mostly concerned about how to pass the record id of the
edited record on post without exposing the record ID to the html
source.
You don't. You store that ID in a session variable.

This may become a problem if you are editing several records at the same
time. though. Think about using ID hashes, or random tickets.

--
----------------------------------
Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

Un ordenador no es un televisor ni un microondas, es una herramienta
compleja.
Mar 11 '07 #4
dino d. wrote:
On Mar 9, 10:46 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
>dino d. wrote:
>>hi everyone- my subject pretty much says it all- is there a secure way
to do this? the non-secure ways are, as i understand it, to populate
a listbox with indices as names, or maybe use a hidden control. is the
only secure way with sessions? i was also thinking about perhaps
creating a meta table that says who is editing which record right
now. any advice?
thanks,
dino
Define "Editing a MySQL record".

What happens if the user brings up an edit form then shuts off the
computer, for instance?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================


i'm really mostly concerned about how to pass the record id of the
edited record on post without exposing the record ID to the html
source. thanks for any help.

dino

(Top posting fixed)

Lots of ways. As Iván suggested, use a session variable. A hash doesn't
work (not reversible), but you could also append a hidden string (known
only to you) and encrypt it.

But the question begs - why worry about exposing the id? It's only an
identifier to a row, and should not have any meaning of its own. If
you're trying to obscure it for security reasons, it won't work.
Obscurity is no security. Rather you need to have other means of
verifying if this person is authorized to edit the row.

P.S. Please don't top post. Thanks.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Mar 11 '07 #5
Jerry Stuckle wrote:
Lots of ways. As Iván suggested, use a session variable. A hash doesn't
work (not reversible),
It works, if you store a rainbow table as a session variable (to reverse the
hash when the client posts the data), and expose the hash to the client.

The ticket idea is similar, but uses random strings instead of hashes.

--
----------------------------------
Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

Un ordenador no es un televisor ni un microondas, es una herramienta
compleja.
Mar 11 '07 #6
Iván Sánchez Ortega wrote:
Jerry Stuckle wrote:
>Lots of ways. As Iván suggested, use a session variable. A hash doesn't
work (not reversible),

It works, if you store a rainbow table as a session variable (to reverse the
hash when the client posts the data), and expose the hash to the client.

The ticket idea is similar, but uses random strings instead of hashes.
true - but wouldn't a reversible encryption be a lot easier?

But either way - it's still security by obscurity - which is no security
at all.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Mar 11 '07 #7
>
But the question begs - why worry about exposing the id? It's only an
identifier to a row, and should not have any meaning of its own. If
you're trying to obscure it for security reasons, it won't work.
Obscurity is no security. Rather you need to have other means of
verifying if this person is authorized to edit the row.

ok, sorry for the top posting, by "top posting" you mean writing your
reply at the top, right? back to the question - i don't want to give
the user an opportunity to monkey around with the html somehow, and
send back a bogus response via a POST variable. I want to ensure 2
things- first, that the person is authorized to edit this row, and
second, that this is the row that he or she is authorized to edit. It
sounds like sessions are the way to go with some kind of encyrption.
Is that the generally accepted way of doing this?

Thanks again,
Dino

Mar 11 '07 #8
>ok, sorry for the top posting, by "top posting" you mean writing your
>reply at the top, right? back to the question - i don't want to give
the user an opportunity to monkey around with the html somehow, and
Using CURL is much easier than monkeying around with HTML, and you
can't stop it.
>send back a bogus response via a POST variable.
I want to ensure 2
things- first, that the person is authorized to edit this row, and
Then when the user submits his edit of the row, you CHECK that he
is authorized to edit that row *WHEN HE SUBMITS IT*. This is not
the same thing as checking what the user is authorized to edit when
he pulls up a screen of records he might edit, or checking when he
starts the edit (although those are a good idea ALSO). Why? Between
those times, the user might have had his account cancelled, or he
might not own the record any more, or he's changed jobs so he doesn't
have the authority to edit records any more, or whatever.
>second, that this is the row that he or she is authorized to edit. It
sounds like sessions are the way to go with some kind of encyrption.
Is that the generally accepted way of doing this?
Data in sessions is not sent to the browser nor accepted back from
it, so the user cannot directly tinker with it. It's good for
keeping track, for example, of who if anyone is logged in for this
session. But editing inherently involves getting input from the
user. Check that he has the authority AT THE TIME YOU'RE MAKING
THE CHANGES, as well as earlier. The editing process will probably
involve several checks that the user has the authority to edit: don't
skimp on these.
Mar 11 '07 #9
dino d. wrote:
ok, sorry for the top posting, by "top posting" you mean writing your
reply at the top, right? back to the question - i don't want to give
the user an opportunity to monkey around with the html somehow, and
send back a bogus response via a POST variable.
Then don't allow your users to get anywhere near a web browser.
I want to ensure 2 things- first, that the person is authorized to edit
this row,
Use a decent auth, and implement some kind of ACLs.
and second, that this is the row that he or she is authorized to
edit.
Easy - echo the row primary key. No need to obfuscate it. In your "security"
paranoia, you are forgetting about more important things - like data
integrity and concurrency.
It sounds like sessions are the way to go with some kind of
encyrption. Is that the generally accepted way of doing this?
The accepted way to do this is to learn about the possible meanings
of "security" in computer science (integrity, confidentiality, reliability,
non-repudiation, etc etc). Then, think about what you *really* need in your
app.

--
----------------------------------
Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

http://acm.asoc.fi.upm.es/~mr/
Proudly running Debian Linux with 2.6.18-4-amd64 kernel, KDE3.5.3, and PHP
5.2.0-10 generating this signature.
Uptime: 23:13:59 up 1 day, 9:35, 3 users, load average: 0.92, 0.87, 0.66

Mar 11 '07 #10
dino d. wrote:
>But the question begs - why worry about exposing the id? It's only an
identifier to a row, and should not have any meaning of its own. If
you're trying to obscure it for security reasons, it won't work.
Obscurity is no security. Rather you need to have other means of
verifying if this person is authorized to edit the row.


ok, sorry for the top posting, by "top posting" you mean writing your
reply at the top, right? back to the question - i don't want to give
the user an opportunity to monkey around with the html somehow, and
send back a bogus response via a POST variable. I want to ensure 2
things- first, that the person is authorized to edit this row, and
second, that this is the row that he or she is authorized to edit. It
sounds like sessions are the way to go with some kind of encyrption.
Is that the generally accepted way of doing this?

Thanks again,
Dino
Yep, that's right. This one is much better.

And there is no way you can prevent the user from monkeying around with
the html.

For instance - I can display the html source, copy it to notepad and
edit it to my hearts content. Save it on my own machine and load it in
to the browser. When I submit it it will still go to your site. The
whole think may take less than two minutes.

Yes, you can save the data in the session. But Gordon has some very
valid comments on why you need to determine if they can edit the row at
the time the user submits the edit request.

Any dangerous operation (i.e. altering a database entry) needs to be
authorized at the time of the submission.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Mar 12 '07 #11

Any dangerous operation (i.e. altering a database entry) needs to be
authorized at the time of the submission.
ok - so just to clarify, what is the technique to do this- with a meta
table on the database server, i.e.:
Table Permissions:

UserID: int TableID: int RecordID: int Permission: int

how about with sessions? if anything else, can you give some
specific techniques as to how to do this? what i'm really trying to
get to is, what is the generally accepted, easiest (built into php?)
way to ensure that the user is authorized to edit a row upon
submission? thanks for all the posts.

thanks again,
dino

Mar 12 '07 #12
>Any dangerous operation (i.e. altering a database entry) needs to be
>authorized at the time of the submission.

ok - so just to clarify, what is the technique to do this- with a meta
table on the database server, i.e.:
Table Permissions:

UserID: int TableID: int RecordID: int Permission: int
>how about with sessions?
A quite reasonable rule is that only a particular session can alter
data (say, a shopping cart contents) associated with that session.
>if anything else, can you give some
specific techniques as to how to do this? what i'm really trying to
get to is, what is the generally accepted, easiest (built into php?)
way to ensure that the user is authorized to edit a row upon
submission? thanks for all the posts.
There are all sorts of different rules possible, and it depends
largely on the site and what it's for. Usually, these are related
to "business rules", for example, customers can't alter prices or
give discounts to other customers. Only supervisors can approve
refunds or orders over $1,000. You can't cancel an order after it
has been shipped (at least not directly; talk to customer service).
1. No one is allowed to edit anything through the web.
("read only" informational site, porn site)
2. Only site admins are allowed to edit anything.
("read only" informational site, porn site)
3. Users may sign up and create their own accounts. Subsequently,
they may edit their own contact information and password. Users may
create and edit their own orders in process of creation, but not
after submission. Customer service reps may edit any order.
(e-commerce site, perhaps)
4. Users may sign up and create their own (class 0, initially) accounts.
Subsequently, they may edit their own contact information and password.
Class 2 accounts and higher may read posts. Class 5 accounts and
higher may reply to posts. Class 6 accounts and higher may start a
new thread. Class 14 accounts and higher may delete any post.
Class 15 accounts may alter the class of any account.
No one may edit (other than by deleting) existing posts.
(forum site with multiple access levels)
5. Anyone may edit anything (I've heard Wikipedia described this way).
6. Anyone may post anything. No one may cancel anything.
(USENET).

The concept of a "user" needs to tie in with the existing setup of your
site. If a user can edit "his own" records, there needs to be some way
to determine who owns a record. Perhaps "a user's orders" are defined
as orders created by that user while logged in under that account. An
e-commerce site that lets users create orders on another user's bill in an
unrestricted manner won't last long.

Mar 13 '07 #13

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

Similar topics

5
by: Lars Behrens | last post by:
Hi there! For a web project I need a little expert help. I don't have written much code yet, just been fiddling around a bit, testing and planning. The web site will have a submission page for...
4
by: Ace Alexander | last post by:
My current Mysql database has a table with a Text field and a few blob fields. The average record can range from 500kb to 5mg, the bulk coming from the blob fields. I select from each record based...
1
by: Kyndig | last post by:
Hi group, I am working on retrieving/storing information in a MySQL database that requires the rows of the db scheme to be expandable. As an example of what I am trying to do: You want to store...
3
by: Don Seckler | last post by:
I have a data entry form called Draw. This form is used to enter data in the table called Draw. The table has the following fields: WholesalerID, MagID, IssueID, CopiesDist, and the index is...
5
by: Ross A. Finlayson | last post by:
Hi, I'm scratching together an Access database. The development box is Office 95, the deployment box Office 2003. So anyways I am griping about forms and global variables. Say for example...
5
by: Guadala Harry | last post by:
What are my options for *securely* storing/retrieving the ID and password used by an ASP.NET application for accessing a SQL Server (using SQL Server authentication)? Please note that this ID and...
8
by: =?Utf-8?B?bWlrZWc=?= | last post by:
Hi, I am building a small Help Desk application for my company and need to be able to edit "open" help desk issues. I use a simple datagrid to display each issue (6 per page) , with an Edit...
2
by: iwasinnihon | last post by:
I am fairly new to MS Access and I am creating a simple database. I have created a form that has information from a three different tables displayed in three different list boxes(listbox1,...
1
by: javediq143 | last post by:
Hi All, This is my first post in this forum. I'm developing a CMS for my latest website. This CMS is also in PhP & MySQL. I'm done with the ADD section where the Admin can INSERT new records in...
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: 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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
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
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...

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.