Author Topic: Website Security  (Read 3986 times)

Offline Sunchaser

  • Game Owner
  • Level 23
  • *
  • Posts: 296
  • Reputation: +3/-0
  • Game Owner
    • View Profile
    • Medieval Europe
Re: Website Security
« Reply #25 on: December 22, 2008, 03:02:00 PM »
Nice to know, this happened to me once... and with bank accounts!

Now, when i write the function for updating money i do

if (money + delta) < 0
   money = 0

:

Offline Chris

  • Game Owner
  • Level 35
  • *
  • Posts: 2,217
  • Reputation: +28/-1
    • View Profile
Re: Website Security
« Reply #26 on: December 22, 2008, 03:39:43 PM »
Magic quotes is actually deprecated in php v5.3.0. And will be fully removed in php 6.0.0 as it is highly discouraged.
Yes, they depreciate all the cool things, like font tag for example. But it won't stop my love for them, no way :D
I though that in PHP 6 MagicQuotes will be turnd OFF by default, not removed?

As for negative rollover it was interoduced in MySQL 5-something. If you are using MySQL 4 you are safe (I'm 100% sure of this because I'm using the UNSIGNED side effect to "fix" some concurency problems).

Offline codestryke

  • Administrator
  • Level 33
  • *****
  • Posts: 589
  • Reputation: +22/-0
    • View Profile
    • eXtremeCast Games
Re: Website Security
« Reply #27 on: December 22, 2008, 11:47:40 PM »
As for negative rollover it was interoduced in MySQL 5-something. If you are using MySQL 4 you are safe (I'm 100% sure of this because I'm using the UNSIGNED side effect to "fix" some concurency problems).

Nope its been there since 3.x because I've been bit by every version since then.
It's actually not a bug it is the defined behavior the mysql developer group wants, go figure.

For me I just made the damn thing signed at be done with it, the mySQL docs recommend using an inline IF in your query. To much work for me ;)

Creating online addictions, one game at a time:

Offline Chris

  • Game Owner
  • Level 35
  • *
  • Posts: 2,217
  • Reputation: +28/-1
    • View Profile
Re: Website Security
« Reply #28 on: December 23, 2008, 06:02:54 AM »
As for negative rollover it was interoduced in MySQL 5-something. If you are using MySQL 4 you are safe (I'm 100% sure of this because I'm using the UNSIGNED side effect to "fix" some concurency problems).

Nope its been there since 3.x because I've been bit by every version since then.
It's actually not a bug it is the defined behavior the mysql developer group wants, go figure.

For me I just made the damn thing signed at be done with it, the mySQL docs recommend using an inline IF in your query. To much work for me ;)
Nope it does not work like that in MySQL 4.1. I used to have negative gold (concurrency) caused by two players attacking the same target to get its gold. After I changed the gold field to UNSIGNED the problem was 'solved'. I never got rollover and believe me, with this amout of player I would know if it happened for sure. MySQL 4.1 does not have negative rollover, 100% sure and tested under heavy load.


Offline codestryke

  • Administrator
  • Level 33
  • *****
  • Posts: 589
  • Reputation: +22/-0
    • View Profile
    • eXtremeCast Games
Re: Website Security
« Reply #29 on: December 23, 2008, 12:30:26 PM »
From the MySQL 3.23, 4.0, 4.1 Reference Manual:

http://dev.mysql.com/doc/refman/4.1/en/cast-functions.html

Or search on "mysql 4 unsigned subtraction" via google.
Creating online addictions, one game at a time:

Offline codestryke

  • Administrator
  • Level 33
  • *****
  • Posts: 589
  • Reputation: +22/-0
    • View Profile
    • eXtremeCast Games
Re: Website Security
« Reply #30 on: December 23, 2008, 01:05:32 PM »
I do want to point out that the rollover problem was never able to be duplicated by us or anyone in our games. The game(s) ran fine for a very long time then it hit us out of no where. It didn't correlate to lag or even very busy times either it just happened when it happened.

First time it through me for a loop for weeks because I didn't even think of the database, all I thought of was checking all my inputs for either a SQL injection or for accepting a negative value ;)



Creating online addictions, one game at a time:

Offline Chris

  • Game Owner
  • Level 35
  • *
  • Posts: 2,217
  • Reputation: +28/-1
    • View Profile
Re: Website Security
« Reply #31 on: December 23, 2008, 02:31:53 PM »
You mean, most of the time 0-1=0 but sometimes 0-1=255 (UNIGNED TINY INT)? Just like that, without any reason?!

Offline codestryke

  • Administrator
  • Level 33
  • *****
  • Posts: 589
  • Reputation: +22/-0
    • View Profile
    • eXtremeCast Games
Re: Website Security
« Reply #32 on: December 23, 2008, 11:37:02 PM »
For me yes.

I know there was something else going on with the account, attack, bank deposit, a purchase but like I said I tried to duplicate the error and never could. It was a multi access error, if there was never multi access to the account data then now it would never do that just automatically.
Creating online addictions, one game at a time:

Offline Chris

  • Game Owner
  • Level 35
  • *
  • Posts: 2,217
  • Reputation: +28/-1
    • View Profile
Re: Website Security
« Reply #33 on: December 24, 2008, 05:21:08 AM »
Hmmm
The only explanation I can think of is that MySQL uses differently UNSIGNED - SIGNED  and UNSIGNED - UNSIGNED combinations. I always use "something=something-$constant" with plenty of multi access instances. Seems that constant is always treated as SIGNED that's why I never got a rollover. In your case you probably had one query (like auction) and used non constant that was declared as UNSIGNED, so you got 2x UNSIGNED (like "player.money=player.money-auction.price") and another (like "player.money=player.money-$const"). But still you should be able to duplicate this...

I got once rollover in PHP but it was always duplicatable.

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal