def create
@user = User.new(params[:user])
@title = "Sign up"
render 'new'
end
So the end user can mess around with the form, add is_admin=1 to the other CGI params and end up with an admin account. (Or similar.) Fabulous. def create
@user = User.new(params[:user])
@title = "Sign up"
render 'new'
end
So the end user can mess around with the form, add is_admin=1 to the other CGI params and end up with an admin account. (Or similar.) Fabulous.(1) The book uses test-driven development for the most part; the snippet you pasted is just enough to get the "failed signup" test to pass, and is not the full implementation. (2) The code you copied doesn't even save the user, so there's no potential security breach at this point. (3) There's no admin attribute yet. (It's coming in Chapter 9.) (4) The User model is protected by attr_accessible in any case, as discussed in Chapter 5 (http://www.railstutorial.org/chapters/modeling-and-viewing-u...). There's no way to tell from inspecting a controller action whether or not there's a security breach at the model level.
N.B. Just yesterday I exchanged notes with Yehuda Katz on this very subject; he and Carl Lerche both agree that Rails should close the attr_accessible security hole by default, much as Rails 3 now escapes the output of Embedded Ruby by default. My hope is that we'll see this implemented in Rails 3.x, for some value of x.