Webhook Issue while using Secret #1908

Closed
opened 2025-12-29 17:20:17 +01:00 by adam · 0 comments
Owner

Originally created by @WilliamMarti on GitHub (Aug 7, 2018).

Environment

  • Python version: Python v3.5.2
  • NetBox version: v2.4.1

Steps to Reproduce

Create Webhook with Secret configured. Do some action within Netbox to actually trigger the webhook, in my case creating an IP address.

Expected Behavior

I have a Flask middleware app running that should be accepting the POST once the webhook is triggered. Without a Secret I am able to successfully print out the POSTed payload to my console.

Observed Behavior

With a secret configured in my webhook I receive nothing on my Flask app, not even an error.

Getting the following traceback from the django-rq job info page in the admin panel:

Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/rq/worker.py", line 793, in perform_job
rv = job.perform()
File "/usr/local/lib/python3.5/dist-packages/rq/job.py", line 599, in perform
self._result = self._execute()
File "/usr/local/lib/python3.5/dist-packages/rq/job.py", line 605, in _execute
return self.func(*self.args, **self.kwargs)
File "/opt/netbox/netbox/extras/webhooks_worker.py", line 41, in process_webhook
hmac_prep = hmac.new(bytearray(webhook.secret, 'utf8'), prepared_request.body, digestmod=hashlib.sha512)
File "/usr/lib/python3.5/hmac.py", line 144, in new
return HMAC(key, msg, digestmod)
File "/usr/lib/python3.5/hmac.py", line 84, in init
self.update(msg)
File "/usr/lib/python3.5/hmac.py", line 93, in update
self.inner.update(msg)
TypeError: Unicode-objects must be encoded before hashing

Should my secret be in some sort of format?

Originally created by @WilliamMarti on GitHub (Aug 7, 2018). ### Environment * Python version: Python v3.5.2 * NetBox version: v2.4.1 ### Steps to Reproduce Create Webhook with Secret configured. Do some action within Netbox to actually trigger the webhook, in my case creating an IP address. ### Expected Behavior I have a Flask middleware app running that should be accepting the POST once the webhook is triggered. Without a Secret I am able to successfully print out the POSTed payload to my console. ### Observed Behavior With a secret configured in my webhook I receive nothing on my Flask app, not even an error. Getting the following traceback from the django-rq job info page in the admin panel: Traceback (most recent call last): File "/usr/local/lib/python3.5/dist-packages/rq/worker.py", line 793, in perform_job rv = job.perform() File "/usr/local/lib/python3.5/dist-packages/rq/job.py", line 599, in perform self._result = self._execute() File "/usr/local/lib/python3.5/dist-packages/rq/job.py", line 605, in _execute return self.func(*self.args, **self.kwargs) File "/opt/netbox/netbox/extras/webhooks_worker.py", line 41, in process_webhook hmac_prep = hmac.new(bytearray(webhook.secret, 'utf8'), prepared_request.body, digestmod=hashlib.sha512) File "/usr/lib/python3.5/hmac.py", line 144, in new return HMAC(key, msg, digestmod) File "/usr/lib/python3.5/hmac.py", line 84, in __init__ self.update(msg) File "/usr/lib/python3.5/hmac.py", line 93, in update self.inner.update(msg) TypeError: Unicode-objects must be encoded before hashing Should my secret be in some sort of format?
adam added the type: bugstatus: accepted labels 2025-12-29 17:20:17 +01:00
adam closed this issue 2025-12-29 17:20:17 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#1908