Skip to content

CLOUDSTACK-9099: SecretKey is returned from the APIs - Fixed - #1152

Closed
kansal wants to merge 1 commit into
apache:masterfrom
kansal:CLOUDSTACK-9099
Closed

kansal wants to merge 1 commit into
apache:masterfrom
kansal:CLOUDSTACK-9099

Conversation

@kansal

@kansal kansal commented Dec 2, 2015

Copy link
Copy Markdown
Contributor

The current implementation of User and account management API (in general) return the secret key as a user or account response.
Fix: Added a new API to explicitly return the secretKey and removed it from the user and account response.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add an check before setting the keys to check that keys has a length = 2 to avoid an ArrayIndexOutOfBoundsException. If the length is not equal to 2, throw an IllegalStateException.

@kansal

kansal commented Dec 4, 2015

Copy link
Copy Markdown
Contributor Author

@jburwell Sure!! Will look into these. Adding the test cases and some UI changes for this to work. Will update the PR.

@DaanHoogland

Copy link
Copy Markdown
Contributor

@kansal looking forward to your update. your intended change makes sense

@kansal

kansal commented Dec 8, 2015

Copy link
Copy Markdown
Contributor Author

@jburwell @DaanHoogland @kishankavala Have included some changes related to the UI. Now after generating the keys from UI, after ListUserCmd() api, listKeysCmd() will be called to fill the secret key as I have removed it from the response value of other API's.
Also added a test in which a normal user tries to call the listKeysCmd() for the admin account and hence giving a permission denied exception.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about using LOGGER as a name for this static final? would be more in line with standards

@DaanHoogland

Copy link
Copy Markdown
Contributor

@kansal looks good, but for a change like this I would like a marvin test to prove it and guarantee it's continued functioning/functionality Do you see chance to add that?

@kansal

kansal commented Dec 10, 2015

Copy link
Copy Markdown
Contributor Author

@DaanHoogland Sure will try. Will take some time as I have to go through the documentation first.

@kansal

kansal commented Dec 17, 2015

Copy link
Copy Markdown
Contributor Author

Have updated this PR. Instead of directly removing the secret key from response, I have deprecated that as many regressions were using the secret key from those APIs for authentication. Maybe from next major release we can remove that.

@DaanHoogland marvin test cases on the way!!!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default should be false! this is a security issue.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with @DaanHoogland, it is easy enough to enable again should people need it. Is this setting available to the user or does it need to be added to the database as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@remibergsma It is a part of global config and the admin can change it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kansal I agree with @DaanHoogland and @remibergsma -- it's about reasonable and secure defaults. We should not configure a management server insecurely by default.

@DaanHoogland

Copy link
Copy Markdown
Contributor

@kansal when you say 'I have deprecated that as many regressions were using the secret key from those APIs for authentication', I think we should adjust those regression test to set the setting to true. Let's not do consessions to security for the sake of testing.

@kansal

kansal commented Jan 1, 2016

Copy link
Copy Markdown
Contributor Author

@DaanHoogland Agreed with that point. But its not only about the testing. I'm sure many people will be using it in their own integration. I think we should not change the response immediately like this without informing or making a noise about it. And it is because of this concern only, I added a flag for enabling/disabling the secret key in response.

@DaanHoogland

Copy link
Copy Markdown
Contributor

@kansal I don't agree that making noise first is the way to go. We should disable the return of the key first and document it. Security demands that we play it that way. We can allow users to enable this insecure bahaviour by setting a flag somewhere but it should not be default and catch the unaware users of guard. It will be work in the integration tests but that just will have to happen.

@jburwell

jburwell commented Jan 4, 2016

Copy link
Copy Markdown
Contributor

@DaanHoogland I complete agree with you regarding exposing credential information. The best practice when credentials are lost is to require that they be changed. This approach makes the access to the sensitive information obvious to all users -- making it impossible for an attacker to hide such a breach.

In the past, we have removed sensitive data from existing API responses. For example, for CVE-2015-3251, we removed exposure of KVM credentials from the listHosts call. Therefore, as a project, we have previously determined that security should trump API backwards compatibility. It should most certainly be prioritized over making the task of integration testing easier.

@kansal

kansal commented Jan 4, 2016

Copy link
Copy Markdown
Contributor Author

cc @DaanHoogland @jburwell Okay. Agreed with that. So I am setting the default value to false but for running tests and maybe some other existing integration we will have to make that value to true. Is that fine? Of course we need to fix the existing test cases so that maybe from the next release we can get away with this thing completely?

@DaanHoogland

Copy link
Copy Markdown
Contributor

@kansal did you get to this yet?

@kansal

kansal commented Mar 29, 2016

Copy link
Copy Markdown
Contributor Author

@DaanHoogland I am not sure of the amount of work that needs to be done for fixing all the existing test cases. Will revisit this and update. I still personally think that going with the optional parameter presently and assuming( and making sure) that the new test cases are written in compliance with this API will be a good way to go forward. Your views?
PS: I am still not very versed with the test case suits. Will check and revisit this.

@DaanHoogland

Copy link
Copy Markdown
Contributor

@kansal as the complexity is unknown I would just go ahead and update the pr. We'll see the damage and think of fixes as we go. As for setting the value to true for existing tests, fine. as long as the default is false. the fix (setting it to true for some test cases) is trivial and will probably not be needed very often. Who is going to check a response for a private key unless they really need it.

@yadvr

yadvr commented May 2, 2016

Copy link
Copy Markdown
Member

@kansal can you rebase against latest master and share state of your PR, thanks

@DaanHoogland @jburwell do we still have outstanding issues on PR; do we want this or not? thanks

@DaanHoogland

Copy link
Copy Markdown
Contributor

@kansal please go ahead and remove the key from the response. We'll test run it and add fixes to tests if needed. (cc @rhtyd my last comment is still valid)

@kansal

kansal commented May 2, 2016

Copy link
Copy Markdown
Contributor Author

@DaanHoogland sure. Will rebase and keep the default value to false.

description = "This command allows the user to query the seceret and API keys for the account",
responseObject = RegisterResponse.class,
requestHasSensitiveInfo = false,
responseHasSensitiveInfo = true)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the version annotation to indicate that this command was added for 4.9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants