Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chef Server API should not allow client-names with newline characters #124

Open
PrajaktaPurohit opened this issue Mar 6, 2015 · 5 comments
Labels
Status: To be prioritized Indicates that product needs to prioritize this issue. Triage: Try Reproducing Indicates that this issue needs to be reproduced. Type: Bug Does not work as expected.

Comments

@PrajaktaPurohit
Copy link
Contributor

In the current chef-server we can create a client with name "staging-mike\n".
That should not be allowed.

REF: #90

Issue noted in : https://getchef.zendesk.com/agent/tickets/3212

@marcparadise
Copy link
Member

Similar to #90, I tried to recreate this. I got a 400 response from the server with the message
{"error":["Invalid client name 'testing_\nclient' using regex: 'Malformed client name. Must be A-Z, a-z, 0-9, _, -, or .'."]}

The input here was:

"(<<-EOM)"
testing
client
EOM

Is it possible that this client was modified through an external means?

@stevendanna
Copy link
Contributor

This is possible via the API on a PUT to an existing client:

chef > api.get("/clients").keys
 => ["acme-validator", "foobar"]
chef > api.put("/clients/foobar", name: "foobar\n"); nil
 => nil
chef > api.get("/clients").keys
 => ["acme-validator", "foobar\n"]

@sdelano sdelano added this to the accepted-minor milestone Jun 10, 2015
@n4rk0o
Copy link

n4rk0o commented Oct 13, 2015

Hello,

The solution proposed by stevendanna id not working with Chef Server 12. I tried to change the name with:
chef-shell > clients.transform(":") do |client|
if client.name =~ /borat/i
client.name("barot")
else
nil
end
end

The result indicated that the name changed correctly but after executing the command "clients.all", the name of the client is still always:

name => 'XXXXXX
'
So, with this modification I'm able to access to the client in the web UI of Chef.

@tas50 tas50 added Type: Bug Does not work as expected. and removed bug labels Jan 4, 2019
@ghost
Copy link

ghost commented Jan 10, 2019

Any tips for getting rid of a client with a newline?

@PrajaktaPurohit PrajaktaPurohit added Status: To be prioritized Indicates that product needs to prioritize this issue. Triage: Try Reproducing Indicates that this issue needs to be reproduced. labels Jul 17, 2020
@stevendanna stevendanna removed this from the accepted-minor milestone Sep 29, 2020
@biox
Copy link

biox commented Aug 23, 2021

We solved this by renaming the client from within postgres, and then deleting the client with knife.

For example, if the bad hostname was "foobar\n", I'd do something like this:

opscode_chef=# SELECT * FROM clients WHERE name LIKE 'foobar%' LIMIT 10;
opscode_chef=# UPDATE clients
opscode_chef-# SET name = 'foobar'
opscode_chef-# WHERE
# id is pulled from the SELECT query
opscode_chef-#  id = 'fae12048578e9f7777a66999b9' AND
opscode_chef-#  name LIKE 'foobar%';
UPDATE 1

opscode_chef=# SELECT * FROM clients WHERE name LIKE 'foobar%' LIMIT 10;

Then, optionally, you can delete it with knife:

knife client delete foobar
Do you really want to delete foobar? (Y/N) y
Deleted client[foobar]

This worked fine for us, but may have consequences. Perform at your own risk! 🤷

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: To be prioritized Indicates that product needs to prioritize this issue. Triage: Try Reproducing Indicates that this issue needs to be reproduced. Type: Bug Does not work as expected.
Projects
None yet
Development

No branches or pull requests

7 participants