Reckless mishandling of sensitive information can have dire consequences, including widespread data leaks, compromised privacy, and financial losses. Implement robust security measures to mitigate this.
1def sensitive_information_leak_noncompliant
2 # Noncompliant: User-controlled data is passed in find.
3 @user = User.find(params[:id])
4
5 respond_to do |format|
6 format.html
7 format.json { render :json => @user }
8 end
9end
1def sensitive_information_leak_compliant
2 # Compliant: Argument in find is not user-controlled.
3 @user = User.find(session[:id])
4
5 respond_to do |format|
6 format.html
7 format.json { render :json => @user }
8 end
9end