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 8043771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:00:56+00:00 2026-06-05T05:00:56+00:00

I am building a simple CRUD app (not using the CRUD module). My model

  • 0

I am building a simple CRUD app (not using the CRUD module).

My model is a simple class with one attribute. the id is implicitly inheritied from Model.

@Entity
public class Account extends Model {

    @Required
    public String domain;
}

The view is as follows. Please note the hidden field with id.

<form class="form-horizontal" action="@{Application.save}" method="POST">
<fieldset>
    <legend>Settings</legend>
    <input type="hidden" name="account.id" value="${account?.id}">

    #{field 'account.domain'}
    <div class="control-group #{if field.error != null} error #{/if}">
        <label class="control-label" for="${field.id}">&{field.name}</label>
        <div class="controls">
            <input type="text" class="input-xlarge" id="${field.id}" value="${field.value}" name="${field.name}">
            <span class="help-inline">${field.error}</span>
        </div>        
    </div>
    #{/field}        

    <div class="form-actions">
        <input class="btn btn-primary" type="submit" value="Save">
    </div>

</fieldset>

I have been able to build a scenario where save,update works.

The way update is done is I read the ID from hidden field, and update the record. If ID is not available, a new record is created.

So the question is: Can the ID be hacked i.e modified so that I change 1 to 2, and assuming a record with 2 exists, it gets overwritten. (I suppose it shouldn’t be difficult with firebug or other plugins).

How do I prevent this? One option I thought of is to read the record with the given Id, if user is allowed to modify it, I allow update, otherwise not. This is still not fool proof because, while the user could be allowed, “wrong” record could be modified.

I imagine this is a known problem and hopefully with a known solution.

Thanks for taking the time to answer my question.

  • 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-05T05:00:58+00:00Added an answer on June 5, 2026 at 5:00 am

    So the question is: Can the ID be hacked i.e modified so that I change
    1 to 2, and assuming a record with 2 exists, it gets overwritten. (I
    suppose it shouldn’t be difficult with firebug or other plugins).

    How do I prevent this? One option I thought of is to read the record
    with the given Id, if user is allowed to modify it, I allow update,
    otherwise not. This is still not fool proof because, while the user
    could be allowed, “wrong” record could be modified.

    Of course, it is possible for an attacker to change the id of the record.

    there are several ways to minimize the impact of this attack.

    1) easiest way – Object fetching:

    Fetch the Object from the database and check if it belongs to the user in question. This will prevent other users from messing around with objects that don’t belong to them, but will not prevent a user to change another object belonging to him. This is an easy way and sufficient in most cases.

    2) more complicated: signing:

    The idea here is to sign the constants you provide to the template and check if the hash still matches after form submission.
    This is very similar to what play does with its session. Its impossible for an attacker to mess around with the constants (e.g. id) and provides the most security.. however, you’ll have more work to do.

    Example:

        public static void someActionDisplayingForm(){
      SomeObject o = ....
      SomeOtherObject o2 = ....
          String constants = o.id + "|" + o2.id;
          String hash = Crypto.sign(constants);
           render(o, o2, hash);
    }
    

    in the template you have

     #{form ...}
       <input type='hidden' name='id1' value='${o.id}' />
       <input type='hidden' name='id2' value='${o2.id}' />
       <input type='hidden' name='hash' value='${hash}' />
    

    in the method processing the form you’ll do

     public static void processing(String id1, String id2, String hash, String otherValues, ...){
       String constants = id1 + "|" + id2;
       String checkHash = Crypto.sign(constants);
        if(!checkHash.equals(hash))
         badRequest();
       ... 
    }
    

    Hope that helps.

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

Sidebar

Related Questions

I'm building a simple Contact Management app with Crud using AngularJS 1.0.0rc8. Getting a
Building a simple app here; the methods in question: static coin class public static
I'm building a simple Grails app for a web development class. For the most
I'm building a simple multi-user (multi-tenant?) App with ASP.NET MVC3 and EF4, one database,
Im building a simple web app in Python using web.py - and was wondering
I'm building a simple API using django-tastypie. The idea is I have two resources:
I'm building simple dictionary application using WPF. I'm using MVVM pattern, databinding and FlowDocument
I am building simple blogging framework using PHP and MySQL, and on the add
I'm building a simple Ruby on Rails plugin and I'm considering using the Set
I'm building a simple chat app with Rails. when a user types in a

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.