Assistive Access - Strange Behaviour

I’m new to this tool and to the forum; my apologies if I’m bringing up a known problem.

I have an Applescript that uses assistive access. It works under Script Editor. OSX behaves very oddly after I give Script Debugger Assistive Access.

I’ve been through this rather amusing cycle 5 or 6 times, the first couple of times I couldn’t believe my eyes.

  • In System Preferences I give Script Debugger Assistive Access.
  • After locking “Security and Privacy” I double check - yup, the box is checked.
  • I run Apple Script with Script Debugger.
  • About halfway through, Script Debugger halts with this error message: “Script debugger is not allowed assistive access”
  • I triple check System Preferences> Privacy> Assistive Access and whaddyaknow - the check box for Sript Debugger is now unchecked!!

The code where the crash occurs is this:

tell application "System Events"
	tell application process theAppName
		set frontmost to true
		set AppUI to UI elements
		if debugLevel ≥ 2 then log {"App UI", AppUI}
	end tell
end tell

I’ve tried setting assistive access from both user and admin accounts, same results.

Any ideas how to proceed?
(OSX 10.12.6 on a late 2015 iMac, Script Debugger 7)

Is Script Debugger in your ?Applications folder? Do you have more than one version on your Mac?

Is System Integrity Protection disabled on your mac?

You can check from Terminal:

csrutil status

Scrip Debugger is recently upgraded, it is in the Applications folder and the only version present

SIP is enabled. I haven’t changed this setting since upgrading to 10.12.6 a few months ago. I’ll experiment wit disabling this and rebooting when I get home from work.

No, I wasn’t suggesting that you disable it at all.

The reason I asked is that the TCC database which controls what’s going on in that Pref pane is under SIP control in 10.12 and later. Therefore, regardless of how many copies of SD you do or don’t have, it should not be possible for the box once checked to become unchecked programmatically.

I don’t mean this to be an advert, but as it goes, I develop a troubleshooting app, which when running, throws a user notification whenever a box has been checked/unchecked in that pref pane (although it’s not supposed to be programmatically possible, there’s a few kinds of malware that use GUI scripting behind an immovable window to trick users into adding stuff in there unwittingly). You could launch my app and then try to reproduce your problem. That’d at least tell you exactly when the ‘unchecking’ is taking place.

DM me if you want to discuss it off list. I’d be quite keen to do so, as on the face of it this looks like a macOS security bug {as well as / rather than} an SD bug.

Phil, I will download your app and see what indication it gives. So far this problem is 100% reproducible. I will try it on a different MAc as well.
I"d be interested to discuss this with you, but what’s DM and how do I access it? I didn’ t realise we had private messaging here.

DM sent! :slight_smile:

I found that the behaviour was not replicated on another Mac with very similar SW. After a safe boot the problem has disappeared. Thanks for all the helpful comments.

I note that the records in TCC.db show SD’s bundle identifier includes its version number:

kTCCServiceAccessibility|com.latenightsw.ScriptDebugger6|0|1|1|˙fi|

so potentially different versions of SD should need separate authorisation.

Also, if the display names of both versions are the same, and the array controller backing the display in the Sys Prefs pane can only handle one entry with the app’s display name, it might account for this weird behaviour.

I need to look into this a bit more though.

Hi Phil
I am basically a “caveman debugger” learning to use modern tools. Wrote my first program on the Olivetti P203 in my father’s office in about 1968.
I got and installed Script debugger 6 in early January after using Script editor for about a year, but didn’t get round to using it until I got Mark’s email that I was entitled to a free upgrade. So the first thing I did was go through the upgrade process, and I didn’t think I had kept version 6.
The idea that there might be two versions did cross my mind, but I checked the applications folder, and yup, there’s only version. So then I thought well maybe the old version info got loaded into the caches for the assistive access control, so I deleted Script Debugger from assistive access, and then added it again by selecting it from the applications folder. Then reran the test case with the same result as before. Tried that 2 or 3 times without success.
What’s an easy way to read TCC.db?

You can read it if you have admin privs on 10.12 or later from the command line (Terminal) with:

sudo sqlite3 /Library/Application\ Support/com.apple.TCC/TCC.db 'select * from access'

Note that you can’t write to it. It’s under SIP protection now.

Yes, it does seem here that if you delete an item from the mac that’s added into TCC.db, it doesn’t delete it from the database, but all you’ll have done there is delete SD7, not SD6, as the items have different entries.

If the problem has returned, I’d be interested to know if the safe boot solves the problem again or whether that was just a coincidence.