- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I am on Zurich.
I have instance "A" and on this instance I have a user account marked as both "machine" and Internal Integration User. This user account is linked to a role which is linked to a REST API's "execute" ACL.
This ACL is linked to a scripted REST API with 2 resources. One of the resources is a POST resource used by another ServiceNow instance (instance B) to create incidents into this instance.
Neither this user through a directly assigned role, nor through a role contained by the ACL role can this user create incidents.
Yet when from instance B I post, it creates incident on instance A.
I have used GlideRecordSecure on instance A in the POST resource.
Any hints?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
The only way I could stop it is by creating another custom role and scripting it in the POST resource script to check if the user has this role or not. This role is not associated with Incident table through ACL. It's just sitting there on its own and this machine account is associated with this role. That's the whole setup now.
The default Deny-Unless ACL and Allow-If (can open your own incidents) ACL allowed this account to have write permissions even though I didn't specifically give it this permission.
Hence GlideRecordSecure() wasn't really helpful as these two ACLs were passing in the Access Analyzer.
ServiceNow needs to give us some other solid way to handle this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi Ankit,
This is my script on the POST resource. I have added lots of comments so it's easier to understand. I have also checked which user creates the incidents and it happens to be the "machine" user I created. So it's interesting.. Code is as below:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @AmolJ
Thanks for sharing the script.
The 1 thing I noticeed is:
var incidentGr = new GlideRecordSecure('incident');
incidentGr.initialize();
...
var newIncidentSysId = incidentGr.insert();Since you've already confirmed that the authenticated user is the machine user, this appears to rule out an authentication issue.
One thing I'd test is whether the platform believes the user has create access at runtime:
gs.info('Can Create Incident: ' + incidentGr.canCreate());Add that immediately before the insert() and check the logs.
Can you check whether canCreate() returns true or false? That will help us determine if the problem is related to ACL evaluation or the way server-side inserts from a Scripted REST API work.
If you found this useful, feel free to mark it as Accept as Solution and Helpful. It makes my day (and helps others too 😉).
Regards,
- Ankit
LinkedIn: https://www.linkedin.com/in/sharmaankith/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
The only way I could stop it is by creating another custom role and scripting it in the POST resource script to check if the user has this role or not. This role is not associated with Incident table through ACL. It's just sitting there on its own and this machine account is associated with this role. That's the whole setup now.
The default Deny-Unless ACL and Allow-If (can open your own incidents) ACL allowed this account to have write permissions even though I didn't specifically give it this permission.
Hence GlideRecordSecure() wasn't really helpful as these two ACLs were passing in the Access Analyzer.
ServiceNow needs to give us some other solid way to handle this.