1

After a form submission using Redux, I am able to see the plain text password in the dev tools meta section. Is this safe? Am I doing something wrong when passing the password down to the reducer? How can I make this more secure?

So in my userSlice I am creating an Async Thunk that accepts user input then grabs the user from my server/database.

export const setUserAsync = createAsyncThunk(
  'user/setUserAsync',
  async (payload, { rejectWithValue }) => {
    try {
      const response = await axios.post('/auth/login', payload);
      const { token, user } = response.data;
      console.log(response);
      localStorage.setItem('user', JSON.stringify(user));
      localStorage.setItem('token', token);
      return user;
    } catch (error) {
      return rejectWithValue(error.response.data);
    }
  }
);

which works as intended. I am then calling the fulfilled reducer to set the user state.

[setUserAsync.fulfilled]: (state, action) => {
  state.user = action.payload;
  state.isLoggedIn = !!action.payload;
}

but in my dev tools I am seeing the following which is plain text of the password I input, in this case it is wrong, but when it's right it shows it just the same.

password screenshot

Dylan L.
  • 1,243
  • 2
  • 16
  • 35
  • You should not send the password in plaintext to the API. It should be converted to a hash value using a hash function and preferable also salting it within the hash function. – BaconPancakes Apr 13 '22 at 08:49
  • 1
    @BaconPancakes So you disagree with https://security.stackexchange.com/questions/110415/is-it-ok-to-send-plain-text-password-over-https ? It is common practice nowadays to simply send the plaintext password. It is in fact what PayPal for example does. The hashing/salting practice was state-of-the-art before HTTPS became mandatory in most modern browsers. – timotgl Apr 14 '22 at 11:09

1 Answers1

2

I don't think you need to be concerned. The production bundle of your app won't have the redux devtools enabled so the password can't linger there. And if you're using proper TLS (see https://security.stackexchange.com/questions/110415/is-it-ok-to-send-plain-text-password-over-https ), the password remains encrypted.

timotgl
  • 2,865
  • 1
  • 9
  • 19