lachlan2k / phatcrack

Modern web-based distributed hashcracking solution, built on hashcat
MIT License
112 stars 9 forks source link

Missing FROM clause in SQL statement #27

Closed JSmith-Aura closed 11 months ago

JSmith-Aura commented 11 months ago

Howdy just getting this error multiple times:

2023/10/25 03:09:12 /app/api/internal/db/job.go:349 ERROR: missing FROM-clause entry for table "attack" (SQLSTATE 42P01)
{"URI":"/api/v1/project/<uuid_omitted>","content_length":"","error":"ERROR: missing FROM-clause entry for table \"attack\" (SQLSTATE 42P01)","error_id":"1cd92282-3ec4-460c-9410-4960937a04bd","latency_ms":2,"level":"error","method":"DELETE" <omitted>
lachlan2k commented 11 months ago

Ah, I think this might be a quirk/edge case when you delete a project that has an attack with no jobs in it.

In the logs from the Postgres container, it should hopefully show the SQL query that gave the error (docker compose logs | grep 1cd92282-3ec4-460c-9410-4960937a04bd -B 5 -A 5 will hopefully help), can you send that here? (with redactions of course)

I'll try to reproduce and fix tonight.

JSmith-Aura commented 11 months ago
2023/10/28 12:52:19 /app/api/internal/db/agent.go:181 SLOW SQL >= 200ms
[253.209ms] [rows:1] UPDATE "agents" SET "agent_info"='{AgentStatusHealthy v0.1.2 2023-10-28 12:52:19.067199604 +0000 UTC m=+1506567.103163316 0001-01-01 00:00:00 +0000 UTC 0001-01-01 00:00:00 +0000 UTC [{015c7acf-309b-4ed4-a3c8-d1e43e65efe8 1149989} {1b82c71a-49b7-4f6e-8cd4-115788202fbc 29663964096} {203a6b55-a906-4e86-9ba9-8a44faf9434a 41} {2377bb37-08ce-4c8f-9752-d9de2512b9bb 62144} {273a7e5f-a17c-42ec-a54a-9709ca9cf953 17710795} {289b01f9-ac61-44e2-a081-403a4bdf4106 363} {2a148c62-08a6-46d6-a43b-37a85677cc21 76162} {335861ab-8243-40dd-a8be-01e11f03bbcc 5068821} {3aa89103-176c-4b1c-8853-66ce68644374 5198204198} {419c1794-e0d6-45c6-847f-d04e93633b0e 139921497} {45fcfaaa-4b13-4d6f-a035-eb517462468d 7804549} {471ef721-e30e-4879-bcc9-a2bbc2f1ef0e 4921930500} {52a9c1fa-fcba-4af4-80ca-8cd26475392b 6950} {55f8f566-f4c4-45fc-b187-4210803beabc 402732} {5b5bfbe6-e25c-42d5-9ecb-47ae80832de8 13527695} {5f84af9a-d9fb-4edf-aa56-573cf44d14e5 4226061726} {705430c4-a15e-47cc-ae3c-f0af49a9f447 43709} {7985c84a-1a03-45c2-aa05-7fc27364cfbf 24612} {8348586f-2891-476a-8ba4-fad08fb40ef6 202997} {989d9e9c-1ad2-44ac-a0ce-3807074d4622 1531} {ad0a888a-f042-43df-9c25-561da41b47d2 905997312} {b3da55ea-8518-424b-a41a-7a8f66d060da 576} {b6105f4e-c6dd-4059-b9aa-56567cdb3f8c 94581} {c75d4042-80b0-4c61-830a-2ede9e7bdd6c 4500756826} {ddd0b0b4-9676-4d80-9879-7ee0f4b62244 573139} {e743062a-456a-4c0b-b7b8-73dd9c18b20c 716441107} {fab4fc47-ec04-4c7c-8f35-a8b570c916c2 62144} {fc54e3f9-86a6-474d-a168-8399b3ae411a 286798}] []}' WHERE "id" = '51e28eba-5108-4c7c-af25-c6e460e4a5d9'
ld-carapace commented 11 months ago
2023/10/28 12:52:19 /app/api/internal/db/agent.go:181 SLOW SQL >= 200ms
[253.209ms] [rows:1] UPDATE "agents" SET "agent_info"='{AgentStatusHealthy v0.1.2 2023-10-28 12:52:19.067199604 +0000 UTC m=+1506567.103163316 0001-01-01 00:00:00 +0000 UTC 0001-01-01 00:00:00 +0000 UTC [{015c7acf-309b-4ed4-a3c8-d1e43e65efe8 1149989} {1b82c71a-49b7-4f6e-8cd4-115788202fbc 29663964096} {203a6b55-a906-4e86-9ba9-8a44faf9434a 41} {2377bb37-08ce-4c8f-9752-d9de2512b9bb 62144} {273a7e5f-a17c-42ec-a54a-9709ca9cf953 17710795} {289b01f9-ac61-44e2-a081-403a4bdf4106 363} {2a148c62-08a6-46d6-a43b-37a85677cc21 76162} {335861ab-8243-40dd-a8be-01e11f03bbcc 5068821} {3aa89103-176c-4b1c-8853-66ce68644374 5198204198} {419c1794-e0d6-45c6-847f-d04e93633b0e 139921497} {45fcfaaa-4b13-4d6f-a035-eb517462468d 7804549} {471ef721-e30e-4879-bcc9-a2bbc2f1ef0e 4921930500} {52a9c1fa-fcba-4af4-80ca-8cd26475392b 6950} {55f8f566-f4c4-45fc-b187-4210803beabc 402732} {5b5bfbe6-e25c-42d5-9ecb-47ae80832de8 13527695} {5f84af9a-d9fb-4edf-aa56-573cf44d14e5 4226061726} {705430c4-a15e-47cc-ae3c-f0af49a9f447 43709} {7985c84a-1a03-45c2-aa05-7fc27364cfbf 24612} {8348586f-2891-476a-8ba4-fad08fb40ef6 202997} {989d9e9c-1ad2-44ac-a0ce-3807074d4622 1531} {ad0a888a-f042-43df-9c25-561da41b47d2 905997312} {b3da55ea-8518-424b-a41a-7a8f66d060da 576} {b6105f4e-c6dd-4059-b9aa-56567cdb3f8c 94581} {c75d4042-80b0-4c61-830a-2ede9e7bdd6c 4500756826} {ddd0b0b4-9676-4d80-9879-7ee0f4b62244 573139} {e743062a-456a-4c0b-b7b8-73dd9c18b20c 716441107} {fab4fc47-ec04-4c7c-8f35-a8b570c916c2 62144} {fc54e3f9-86a6-474d-a168-8399b3ae411a 286798}] []}' WHERE "id" = '51e28eba-5108-4c7c-af25-c6e460e4a5d9'

Hm I don't think this is related. This is just a warning that an agent update query was slow and isn't related to the DELETE query in the original error message you posted. (It also occured 3 days later)

JSmith-Aura commented 11 months ago

Ah yep, sorry. Selected the wrong query

2023/10/25 03:09:12 /app/api/internal/db/job.go:349 ERROR: missing FROM-clause entry for table "attack" (SQLSTATE 42P01)
[0.236ms] [rows:0] SELECT "jobs"."id","jobs"."created_at","jobs"."updated_at","jobs"."deleted_at","jobs"."hashlist_version","jobs"."attack_id","jobs"."hashcat_params","jobs"."target_hashes","jobs"."hash_type","jobs"."assigned_agent_id" FROM "jobs" join attacks on attacks.id = jobs.attack_id join hashlists on hashlists.id = attack.hashlist_id WHERE hashlists.project_id = 'c9c5b27e-442e-418e-890f-21328064de0d' AND "jobs"."deleted_at" IS NULL
{"URI":"/api/v1/project/c9c5b27e-442e-418e-890f-21328064de0d","content_length":"","error":"ERROR: missing FROM-clause entry for table \"attack\" (SQLSTATE 42P01)","error_id":"1cd92282-3ec4-460c-9410-4960937a04bd","latency_ms":2,"level":"error","method":"DELETE","msg":"request error 1cd92282-3ec4-460c-9410-4960937a04bd","remote_ip":"192.168.11.2","response_size":0,"status":500,}
lachlan2k commented 11 months ago

Yep, I see the problem, I typo'd attack instead of attacks on one of the joins. will fix tn