Rate-limiting a SP API

Ariel Aharon
Giga Guru

Hi All,

 

My custom Service Portal is going through a pen-testing phase.

Pen-testers found that they can spam "/api/now/sp/rectangle/<sys_id>?id=<widget_name>" and get 201's.

 

Trying to apply Rate-limit in the platform was not successful as this resource "/api/now/sp" is missing and cannot be selected.

 

How can I apply rate-limit for it for both authenticated and unauthenticated users?

How ServiceNow handles rate-limiting?

2 REPLIES 2

kmohammed
Tera Guru

Hi Ariel,

 

You are hitting a real platform limitation: ServiceNow's REST API rate-limit rules only cover named REST APIs (Table, Scripted REST and so on). /api/now/sp is an internal Service Portal API, so it is not selectable there — that is why you could not find it. There is no out-of-the-box switch to rate-limit that endpoint, so you need a combination of access control and an application-level guard:

 

1. Close the unauthenticated path first

If the widget or page must not create records for anonymous users, make sure the portal page and the widget are not public — require login, and check the ACLs on the table the widget writes to. A pen tester should get an authentication challenge, not a 201, for an unauthenticated submission. That alone removes the worst unauthenticated abuse.

 

2. Throttle the widget itself

Add a server-side check in the widget's server script: record the last submission time for the session or user (for example in a small custom table keyed by user or session), and reject the request if another submission arrives within, say, 10-30 seconds. Do the same check the widget already does before it inserts — never rely on client-side disabling of the button. For a public form, adding reCAPTCHA is also worth doing, so automated spam needs a fresh challenge per submission.

 

3. Rate-limit the record creation, not just the endpoint

If the widget creates a record, enforce the limit where the record is created: a business rule or script that counts recent inserts from the same user/session and blocks duplicates within a short window. That protects you even if the endpoint is reached by another route, and it gives you an audit trail in the logs for the pen test.

 

In general, that is how ServiceNow expects this to be handled: platform rate limits apply to the documented REST APIs, while Service Portal endpoints are protected by authentication, ACLs and widget-level controls. If you need network-level throttling for unauthenticated traffic, that is usually done in front of the instance — a WAF or edge proxy — rather than inside it.

 

If this helped, please mark it as Helpful — and if it solved your issue, I'd be grateful if you accepted it as the solution.

kmohammed
Tera Guru

Hi Ariel,

 

You are hitting a real platform gap: the REST API rate limiting rules (under System Web Services > REST) only cover the APIs and resources you can select there, and the system Service Portal API (/api/now/sp) is not exposed as a selectable resource. That is why you could not apply a rule to it. Platform rate limiting is designed for your own Scripted REST APIs and the Table API, not for the built-in portal endpoints.

 

Also, treat the 201s as the bigger finding, not just a rate problem. A POST to /api/now/sp/rectangle creates a widget instance record (sp_instance), so an unauthenticated caller getting 201s can create records on your instance. Rate limiting would only slow that down; it would not stop it.

 

What to do, in order:

 

1. Close the unauthenticated path first. Make sure the portal and the pages/widgets involved are not public, and check the ACLs on the underlying records (sp_instance and the widget data). An unauthenticated user should not be able to create a widget instance. If the portal must stay public, remove or restrict the widget that posts to this endpoint.

 

2. Require authentication for the portal where possible, so the endpoint is only reachable by logged-in users, and control who can use it through roles and ACLs.

 

3. For actual rate limiting, do it at the edge, in front of the instance. Your WAF / reverse proxy / CDN can throttle requests to /api/now/sp/* by IP, which covers authenticated and unauthenticated callers alike. There is no per-endpoint rate limiter for this system API inside the platform.

 

4. For the pen-test report, note that the platform also applies its own safety nets (concurrent transaction limits and request throttling), but those are instance-wide protections, not a per-endpoint rate limit, so they are not a fix for this finding on their own.

 

In short: fix the access control so anonymous users cannot create records through this endpoint, and enforce throttling at the edge. The missing /api/now/sp entry in the rate limiting rules is expected behaviour, not a misconfiguration.

 

If this helped, please mark it as Helpful — and if it solved your issue, I'd be grateful if you accepted it as the solution.