473,569 Members | 2,617 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Security and statement advise

Hi All

I have 2 question, the first one I hope I don't start an argurment !

How secure is MySQL? I have been asked by a client to create a windows based
application that will control / transfer / edit over HTTP. The data will be
held on a MySQL server hosted on a standard IPSs server. I have been writing
apps to do this for a while, but this client will be holding data that will
be covered under the data protection act so they want to know how secure the
data will be.

So as a general rule how hard (or hopefully not easy) is MySQL to hack, or
how secure is it when it can be accessed by external apps? Dose it just rely
on the usernames and passwords?

The second question, I want some advise on the best way to run a query.

I have a list of product IDs, and I am trying to work out how many of each
of the products was ordered between 2 dates, I have done the following but
it take way to long to come back with the results as there could be up to
3000 products

SELECT product, description, SUM(IF(product = 'productID1', `ord`, 0)) AS
product1IDord, SUM(IF(product = 'productID2', `ord`, 0)) AS productID2ord,
SUM(IF(product = 'productID3', `ord`, 0)) AS productID3ord, (.and so on but
could be up to 3000 products) FROM theTable WHERE (timestamp >= '1234') AND
(timestamp <= '9876') GROUP BY product ORDER BY product

Thanks in advance

Brian


Mar 21 '06 #1
5 1465
Brian wrote:
Hi All

I have 2 question, the first one I hope I don't start an argurment !

How secure is MySQL? I have been asked by a client to create a windows based
application that will control / transfer / edit over HTTP. The data will be
held on a MySQL server hosted on a standard IPSs server. I have been writing
apps to do this for a while, but this client will be holding data that will
be covered under the data protection act so they want to know how secure the
data will be.

Before I would procede with the current path, I would want to search the
web thoroughly to see what others have said. For every method of
protection in most any system are various ways to hack it. For "data
protection act" related data, I would probably want to use a real
database engine.

search the web for MySQL sql injection security


So as a general rule how hard (or hopefully not easy) is MySQL to hack, or
how secure is it when it can be accessed by external apps? Dose it just rely
on the usernames and passwords?
This will all depend upon how well/how much your ISP is willing to lock
the system down to prevent it from being hacked. I would not bet my CC#
on most of them being that secure as they must allow others to use those
servers. You want it secure, have the "customer" host it themselves and
hire the best security people to design and maintain it. Security
cannot be "bolted on", everything from the application to the OS and
database must be designed from the ground up with security as it's core
not an after-thought.


The second question, I want some advise on the best way to run a query.

I have a list of product IDs, and I am trying to work out how many of each
of the products was ordered between 2 dates, I have done the following but
it take way to long to come back with the results as there could be up to
3000 products

SELECT product, description, SUM(IF(product = 'productID1', `ord`, 0)) AS
product1IDord, SUM(IF(product = 'productID2', `ord`, 0)) AS productID2ord,
SUM(IF(product = 'productID3', `ord`, 0)) AS productID3ord, (.and so on but
could be up to 3000 products) FROM theTable WHERE (timestamp >= '1234') AND
(timestamp <= '9876') GROUP BY product ORDER BY product

Add a status field to the record. doing what you are doing will result
in 3000+ fields in the result with a bunch of zeros.. Probably not what
you want.

select product, description, count(product)
from thetable
where timestamp between [date1] and [date2]
and status='ord'
group by product,descrip tion order by product;

Case and Point (small dataset - no date field but the effects are the
same...

mysql> select d,
-> sum(if(d='prod1 ',1,0)) as prod1,
-> sum(if(d='prod2 ',1,0)) as prod2,
-> sum(if(d='prod3 ',1,0)) as prod3,
-> sum(if(d='prod4 ',1,0)) as prod4,
-> sum(if(d='prod5 ',1,0)) as prod5,
-> sum(if(d='prod6 ',1,0)) as prod6
-> from t group by d;
+-------+-------+-------+-------+-------+-------+-------+
| d | prod1 | prod2 | prod3 | prod4 | prod5 | prod6 |
+-------+-------+-------+-------+-------+-------+-------+
| prod1 | 3 | 0 | 0 | 0 | 0 | 0 |
| prod2 | 0 | 1 | 0 | 0 | 0 | 0 |
| prod3 | 0 | 0 | 2 | 0 | 0 | 0 |
| prod4 | 0 | 0 | 0 | 1 | 0 | 0 |
+-------+-------+-------+-------+-------+-------+-------+
4 rows in set (0.01 sec)

mysql> select d,count(*) from t group by d;
+-------+----------+
| d | count(*) |
+-------+----------+
| prod1 | 3 |
| prod2 | 1 |
| prod3 | 2 |
| prod4 | 1 |
+-------+----------+
4 rows in set (0.01 sec)


Thanks in advance

Brian


Mar 21 '06 #2
"noone" <no***@nowhere. com> wrote in message
news:Wa******** ********@newssv r11.news.prodig y.com...
search the web for MySQL sql injection security


Wouldn't any RDBMS be vulnerable to SQL injection if the application is
designed to allow it?
As I understand the idea, SQL injection is a problem in the application, not
the RDBMS.
http://en.wikipedia.org/wiki/SQL_injection

There's a page in the MySQL manual that covers security issues:
http://dev.mysql.com/doc/refman/5.0/en/security.html and its subsections.

I agree that security must include attention to all components of a system.
The security is only as strong as its weakest link. The security plan must
include constant monitoring and logging, too. You can't rely on any
software to be immune to attack forever.

That said, it's a good start to run the RDBMS behind a firewall and disallow
any access to it except directly from the HTTP server hosting the web apps.
If one relies on the security of MySQL to protect the data, it's too late!

And there are books specifically about database security, for example "The
Database Hacker's Handbook: Defending Database Servers" rates 5 stars out of
5 at Amazon.com.
http://www.amazon.com/gp/product/0764578014/
I haven't read it, but it's on my wishlist. :-)

Finally, hacking experts like Kevin Mitnick say that "social hacking" is
harder to prevent than technological hacking. See
http://www.kevinmitnick.com/ and his books like "The Art of Intrusion". One
should not overlook the need to establish policies to define who has access
to the sensitive data within your organization, how they can grant access to
others, and how their access is logged. Training the staff in these
policies is important.

Regards,
Bill K.
Mar 21 '06 #3
"noone" <no***@nowhere. com> wrote in message
news:Wa******** ********@newssv r11.news.prodig y.com...
SELECT product, description, SUM(IF(product = 'productID1', `ord`, 0)) AS
product1IDord, SUM(IF(product = 'productID2', `ord`, 0)) AS
productID2ord, SUM(IF(product = 'productID3', `ord`, 0)) AS
productID3ord, (.and so on but could be up to 3000 products) FROM
theTable WHERE (timestamp >= '1234') AND (timestamp <= '9876') GROUP BY
product ORDER BY product


select product, description, count(product)
from thetable
where timestamp between [date1] and [date2]
and status='ord'
group by product,descrip tion order by product;


I assume the OP's queryuses SUM because it's summing values in the `ord`
column. He uses back-ticks instead of single-quotes, therefore ord is a
column. One cannot assume that ord always contains the value 1, so one must
use SUM instead of COUNT. Otherwise I fully agree with you that this should
be done in one column, not 3000 columns! :)

SELECT product, description, SUM(`ord`) AS productOrd
FROM theTable
WHERE `timestamp` BETWEEN '1234' AND '9876'
GROUP BY product, description
ORDER BY product

Regards,
Bill K.
Mar 21 '06 #4
>>> SELECT product, description, SUM(IF(product = 'productID1', `ord`, 0))
AS product1IDord, SUM(IF(product = 'productID2', `ord`, 0)) AS
productID2ord, SUM(IF(product = 'productID3', `ord`, 0)) AS
productID3ord, (.and so on but could be up to 3000 products) FROM
theTable WHERE (timestamp >= '1234') AND (timestamp <= '9876') GROUP BY
product ORDER BY product


select product, description, count(product)
from thetable
where timestamp between [date1] and [date2]
and status='ord'
group by product,descrip tion order by product;


I assume the OP's queryuses SUM because it's summing values in the `ord`
column. He uses back-ticks instead of single-quotes, therefore ord is a
column. One cannot assume that ord always contains the value 1, so one
must use SUM instead of COUNT. Otherwise I fully agree with you that this
should be done in one column, not 3000 columns! :)

SELECT product, description, SUM(`ord`) AS productOrd
FROM theTable
WHERE `timestamp` BETWEEN '1234' AND '9876'
GROUP BY product, description
ORDER BY product

Regards,
Bill K.

Hi Guys

Thanks for you replies, sorry for the delay in replying, PC problems and got
sided tracked
by another project

I will try and explain a little better what i and trying to do with this
statement

I need to create a SQL statement that brings back a list and sum of all
products ordered between two dates but only for a given supplier, if non
were ordered then sum = 0
I have a table of PRODUCTS and table of ORDERS

SELECT * FROM products WHERE supplier = X < this gives me a list of all the
products that are supplied by a given supplier

Now I need to say, select and sum the products from a given supplier between
two dates and return a list of the product name and how many ordered, if
none then would be 0

eg

Product | Total
Product1 | 78
Product2 | 90
Product3 | 78
Product4 | 0
Product5 | 67
Product6 | 0
....

I have had a play round, but just can' seem to work out what I should be
doing
Hope this explains it better

Cheers

Brian
Apr 9 '06 #5
Brian wrote:
Now I need to say, select and sum the products from a given supplier between
two dates and return a list of the product name and how many ordered, if
none then would be 0

eg

Product | Total
Product1 | 78
Product2 | 90
Product3 | 78
Product4 | 0
Product5 | 67
Product6 | 0
...


Okay, thanks, that is good new information about your query.
You need to use an OUTER JOIN if you want all products, including those
for which there are no orders.

One of the tricks of outer joins is that if you need to restrict the
rows in the left-hand table (speaking of left outer joins here), you can
put the conditions in the WHERE clause. But if you need to restrict the
rows in the right-hand table, you need to put the conditions in the ON
clause, because if you use the WHERE clause, it'll only match rows where
the right-hand table is not null.

SELECT p.product, SUM(o.`ord`) AS Total
FROM products AS p LEFT OUTER JOIN orders AS o
ON (p.product = o.product
AND o.`timestamp` BETWEEN '1234' AND '9876')
WHERE p.supplier = X
GROUP BY p.product
ORDER BY p.product

Regards,
Bill K.
Apr 9 '06 #6

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

Similar topics

2
1581
by: Jack | last post by:
Hi, I am trying to update database from asp. However, the finalupdate field is not working here. The finalupdate field is a Access Database field of type yes/no. Any help/advise is appreciated. Regards THE DYNAMIC SQL STATEMENT: strsql = "UPDATE main SET main.FirstName ='" &l_firstname& "', " & _ "main.LastName = '" &l_lastname& "', " &...
7
2028
by: Paul T. Rong | last post by:
A card where I wrote my name and WID (work group ID) was stolen (unfortunately together with other things), therotically the one who have my name and WID can create the same mdw file which I use with my database. Who can tell me can it have any influnce on the security of my database? If nothing, I will just ignore it.
3
2121
by: Mike Marriott | last post by:
Hello all, Newbie Here (please go easy, you cant make me fell more stupid than I allready do) I have a small, but complex data base, in Access 2000, that I am creating, I have allready starting to add data to it. Alot of data (around 30 hours work, creating and entering data). I did a stupid thing, I protected the thing. . . . Using...
0
1099
by: Patrick.O.Ige | last post by:
This what i got from microsoft! GDluck Dear ASP.NET Customer, This alert is to advise you of the availability of a web page that discusses an investigation Microsoft is currently conducting into public reports of a security vulnerability in ASP.NET. A malicious user could provide a specially-formed URL that could result in the...
4
3497
by: razvan | last post by:
I need advice about adding security to a web service without using WSE, as the clients will run Win98.
19
8353
by: Steve | last post by:
ASP error number 13 - Type mismatch with SELECT...FOR UPDATE statement I got ASP error number 13 when I use the SELECT...FOR UPDATE statement as below. However, if I use SELECT statement without FOR UPDATE, it is fine and no error. I also tried Set objRs = objConn.Execute("SELECT * FROM EMP UPDATE OF EMPNO"), but it still couldn't help. ...
1
1269
by: coosa | last post by:
Dear all, I'm designing a system including the database and the security represents the most crucial aspect of the system; hence for the database security i have implemented the following aspects and need your advise on further aspects or perhaps corrections where by the system is web based using asp.net and under iis 6.0 with https; in the...
2
1377
by: Robert Ellis | last post by:
Hi, I would be grateful for advice on the following. Server 1 (Windows 2003 Server) COMSRV1 VB6 COM ActiveX EXE NETSRV1 .NET (VB2005) .DLL Workstation 1 (Windows XP Professional) APP1 VB6 Standard EXE application
18
2012
by: Earl Anderson | last post by:
First, I feel somewhat embarrassed and apologetic that this post is lengthy, but in an effort to furnish sufficient information (as opposed to too little information) to you, I wanted to supply all of the relevant facts. Second, despite the fact that I think the obvious 'quick' answer to my question would be 'Yes', I am seeking your wisdom...
0
8130
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7979
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6284
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5514
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3643
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1223
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
940
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.