Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7739479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:32:01+00:00 2026-06-01T08:32:01+00:00

This is more thinker than problem. I have a problem with thinking about how

  • 0

This is more “thinker” than problem.
I have a problem with thinking about how to secure javacript.

Let’s say I have this setup:

Main page with iframe in it
Iframe with content.

Now, Let’s say, user has to play a game in the iframe. After he finishes the game the iframe calls:

window.parent.givePrice();

The parent will show modal window:

function givePrice(){
  jQuery('.mask').show();
  jQuery('#won').show();
}

In this modal window they will have something like

Congratulations! you just won a brand new BMW! Click Here to get your price

And after he clicks on the link, his name gets signed (by ajax – not relevant) into Database table “winners”.

(Please remember, this is just an example).

Now This all sounds great, but I can see so many security holes in this. For example if I use firebug and write “givePrice();” it shows me directly the modal that I won, even though I didn’t touch the game at all.

Can someone discuss, what would be the best way to secure example like this?

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T08:32:02+00:00Added an answer on June 1, 2026 at 8:32 am

    The only way to prevent someone cheating is to have the action of making a guess (or whatever it is that lets them “win”) be a round-trip to the server:

    1. Trigger the attempt-to-win (e.g., the user clicks something, or guesses, or whatever it is).
    2. Your page sends the information (including username) to the server.
    3. Server does several things:
      1. Checks rate-limiting related to that account and IP address. (So the user can’t just create a script that tries to win every second for a month, etc.)
      2. Checks the guess or whatever.
      3. If the stars align, records that that user “won”.
    4. Show response to the user.

    If you want to make winning and accepting the win separate steps, you’d do that with another round-trip. On the first trip, the server generates a unique acceptance code and records that the user won and what their acceptance code is on the server. On the second trip, which involves the page sending back the code, checks the code (and several other fraud checks) and records the user accepted.

    There’s no secure way to do this client-side-only. Remember you can’t trust anything sent from the client.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a label on my asp.net page, it looks like this: more info
I might be making this more complicated than I have to. I have a
Let me know if I have to make this more concise, if you don't
This is more of a philosophical question than anything, so give me your thoughts.
(This is more of a curiousity question than any pending disaster :D ) So
This is more a 'wonder why' than a specific issue but look at the
I don't know how to title this more accurately. So I have dynamically generated
Joomla 1.7.2 : I fear I'm making this more difficult than it needs to
I have the following script: http://jsfiddle.net/oshirowanen/pALBV/ How do I make this more dynamic, so
This more a question about the why then 'how-to', yet it has been annoying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.