Pull to refresh

Comments 21

Я считаю, что это всё же проблема elasticsearch, раз уж настройки по умолчанию позволяют подключиться к базе всему миру.
Бесплатная версия elasticsearch не имеет никакой авторизации. Тот кто ее устанавливает, видит это, проверяя работоспособность на 9200 порту.
всё так, но по дефолту сервис открыт по 9200 порту только локально, что бы его открыть извне надо делать отдельные телодвижения.
UFO just landed and posted this here
а можно поподробнее про это? реально хочется понять, почему такое происходит. Про докер слышал от одной «потерпевшей» компании, которой зарепортил находку. Они так и сказали «докер добавляет свои правила в iptables, которые перекрыли ручную настройку правил на уровне Elastic».
UFO just landed and posted this here
ага, спасибо. это многое теперь объясняет ;) становится понятно откуда такой шквал открытых эластиков
Спасибо! Я опытным путем обнаружил что база (в докере) доступна снаружи по 3306, хотя ufw уверял меня в обратном. Понимая что вряд ли косяк ufw я терялся в догадках.
iptables -L
Chain INPUT (policy DROP)
target prot opt source destination
ufw-before-logging-input all — anywhere anywhere
ufw-before-input all — anywhere anywhere
ufw-after-input all — anywhere anywhere
ufw-after-logging-input all — anywhere anywhere
ufw-reject-input all — anywhere anywhere
ufw-track-input all — anywhere anywhere

Chain FORWARD (policy DROP)
target prot opt source destination
DOCKER-USER all — anywhere anywhere
DOCKER-ISOLATION-STAGE-1 all — anywhere anywhere
ACCEPT all — anywhere anywhere ctstate RELATED,ESTABLISHED
DOCKER all — anywhere anywhere
ACCEPT all — anywhere anywhere
ACCEPT all — anywhere anywhere
ACCEPT all — anywhere anywhere ctstate RELATED,ESTABLISHED
DOCKER all — anywhere anywhere
ACCEPT all — anywhere anywhere
ACCEPT all — anywhere anywhere
ACCEPT all — anywhere anywhere ctstate RELATED,ESTABLISHED
DOCKER all — anywhere anywhere
ACCEPT all — anywhere anywhere
ACCEPT all — anywhere anywhere
ufw-before-logging-forward all — anywhere anywhere
ufw-before-forward all — anywhere anywhere
ufw-after-forward all — anywhere anywhere
ufw-after-logging-forward all — anywhere anywhere
ufw-reject-forward all — anywhere anywhere
ufw-track-forward all — anywhere anywhere

Chain OUTPUT (policy ACCEPT)
target prot opt source destination
ufw-before-logging-output all — anywhere anywhere
ufw-before-output all — anywhere anywhere
ufw-after-output all — anywhere anywhere
ufw-after-logging-output all — anywhere anywhere
ufw-reject-output all — anywhere anywhere
ufw-track-output all — anywhere anywhere

Chain DOCKER (3 references)
target prot opt source destination
ACCEPT tcp — anywhere 172.21.0.2 tcp dpt:mysql
ACCEPT tcp — anywhere 172.21.0.3 tcp dpt:http-alt
ACCEPT tcp — anywhere 172.17.0.3 tcp dpt:http

Chain DOCKER-ISOLATION-STAGE-1 (1 references)
target prot opt source destination
DOCKER-ISOLATION-STAGE-2 all — anywhere anywhere
DOCKER-ISOLATION-STAGE-2 all — anywhere anywhere
RETURN all — anywhere anywhere

Chain DOCKER-ISOLATION-STAGE-2 (2 references)
target prot opt source destination
DROP all — anywhere anywhere
DROP all — anywhere anywhere
RETURN all — anywhere anywhere

Chain DOCKER-USER (1 references)
target prot opt source destination
RETURN all — anywhere anywhere

Chain ufw-after-forward (1 references)
target prot opt source destination

Chain ufw-after-input (1 references)
target prot opt source destination
ufw-skip-to-policy-input udp — anywhere anywhere udp dpt:netbios-ns
ufw-skip-to-policy-input udp — anywhere anywhere udp dpt:netbios-dgm
ufw-skip-to-policy-input tcp — anywhere anywhere tcp dpt:netbios-ssn
ufw-skip-to-policy-input tcp — anywhere anywhere tcp dpt:microsoft-ds
ufw-skip-to-policy-input udp — anywhere anywhere udp dpt:bootps
ufw-skip-to-policy-input udp — anywhere anywhere udp dpt:bootpc
ufw-skip-to-policy-input all — anywhere anywhere ADDRTYPE match dst-type BROADCAST

Chain ufw-after-logging-forward (1 references)
target prot opt source destination

Chain ufw-after-logging-input (1 references)
target prot opt source destination
LOG all — anywhere anywhere limit: avg 3/min burst 10 LOG level warning prefix "[UFW BLOCK] "

Chain ufw-after-logging-output (1 references)
target prot opt source destination

Chain ufw-after-output (1 references)
target prot opt source destination

Chain ufw-before-forward (1 references)
target prot opt source destination
ACCEPT all — anywhere anywhere ctstate RELATED,ESTABLISHED
ACCEPT icmp — anywhere anywhere icmp destination-unreachable
ACCEPT icmp — anywhere anywhere icmp source-quench
ACCEPT icmp — anywhere anywhere icmp time-exceeded
ACCEPT icmp — anywhere anywhere icmp parameter-problem
ACCEPT icmp — anywhere anywhere icmp echo-request
ufw-user-forward all — anywhere anywhere

Chain ufw-before-input (1 references)
target prot opt source destination
ACCEPT all — anywhere anywhere
ACCEPT all — anywhere anywhere ctstate RELATED,ESTABLISHED
ufw-logging-deny all — anywhere anywhere ctstate INVALID
DROP all — anywhere anywhere ctstate INVALID
ACCEPT icmp — anywhere anywhere icmp destination-unreachable
ACCEPT icmp — anywhere anywhere icmp source-quench
ACCEPT icmp — anywhere anywhere icmp time-exceeded
ACCEPT icmp — anywhere anywhere icmp parameter-problem
ACCEPT icmp — anywhere anywhere icmp echo-request
ACCEPT udp — anywhere anywhere udp spt:bootps dpt:bootpc
ufw-not-local all — anywhere anywhere
ACCEPT udp — anywhere 224.0.0.251 udp dpt:mdns
ACCEPT udp — anywhere 239.255.255.250 udp dpt:1900
ufw-user-input all — anywhere anywhere

Chain ufw-before-logging-forward (1 references)
target prot opt source destination

Chain ufw-before-logging-input (1 references)
target prot opt source destination

Chain ufw-before-logging-output (1 references)
target prot opt source destination

Chain ufw-before-output (1 references)
target prot opt source destination
ACCEPT all — anywhere anywhere
ACCEPT all — anywhere anywhere ctstate RELATED,ESTABLISHED
ufw-user-output all — anywhere anywhere

Chain ufw-logging-allow (0 references)
target prot opt source destination
LOG all — anywhere anywhere limit: avg 3/min burst 10 LOG level warning prefix "[UFW ALLOW] "

Chain ufw-logging-deny (2 references)
target prot opt source destination
RETURN all — anywhere anywhere ctstate INVALID limit: avg 3/min burst 10
LOG all — anywhere anywhere limit: avg 3/min burst 10 LOG level warning prefix "[UFW BLOCK] "

Chain ufw-not-local (1 references)
target prot opt source destination
RETURN all — anywhere anywhere ADDRTYPE match dst-type LOCAL
RETURN all — anywhere anywhere ADDRTYPE match dst-type MULTICAST
RETURN all — anywhere anywhere ADDRTYPE match dst-type BROADCAST
ufw-logging-deny all — anywhere anywhere limit: avg 3/min burst 10
DROP all — anywhere anywhere

Chain ufw-reject-forward (1 references)
target prot opt source destination

Chain ufw-reject-input (1 references)
target prot opt source destination

Chain ufw-reject-output (1 references)
target prot opt source destination

Chain ufw-skip-to-policy-forward (0 references)
target prot opt source destination
ACCEPT all — anywhere anywhere

Chain ufw-skip-to-policy-input (7 references)
target prot opt source destination
DROP all — anywhere anywhere

Chain ufw-skip-to-policy-output (0 references)
target prot opt source destination
ACCEPT all — anywhere anywhere

Chain ufw-track-forward (1 references)
target prot opt source destination
ACCEPT tcp — anywhere anywhere ctstate NEW
ACCEPT udp — anywhere anywhere ctstate NEW

Chain ufw-track-input (1 references)
target prot opt source destination

Chain ufw-track-output (1 references)
target prot opt source destination
ACCEPT tcp — anywhere anywhere ctstate NEW
ACCEPT udp — anywhere anywhere ctstate NEW

Chain ufw-user-forward (1 references)
target prot opt source destination

Chain ufw-user-input (1 references)
target prot opt source destination
tcp — anywhere anywhere tcp dpt:ssh ctstate NEW recent: SET name: DEFAULT side: source mask: 255.255.255.255
ufw-user-limit tcp — anywhere anywhere tcp dpt:ssh ctstate NEW recent: UPDATE seconds: 30 hit_count: 6 name: DEFAULT side: source mask: 255.255.255.255
ufw-user-limit-accept tcp — anywhere anywhere tcp dpt:ssh
ACCEPT tcp — anywhere anywhere tcp dpt:2375
ACCEPT tcp — anywhere anywhere tcp dpt:2376

Chain ufw-user-limit (1 references)
target prot opt source destination
LOG all — anywhere anywhere limit: avg 3/min burst 5 LOG level warning prefix "[UFW LIMIT BLOCK] "
REJECT all — anywhere anywhere reject-with icmp-port-unreachable

Chain ufw-user-limit-accept (1 references)
target prot opt source destination
ACCEPT all — anywhere anywhere

Chain ufw-user-logging-forward (0 references)
target prot opt source destination

Chain ufw-user-logging-input (0 references)
target prot opt source destination

Chain ufw-user-logging-output (0 references)
target prot opt source destination

Chain ufw-user-output (1 references)
target prot opt source destination

iptables -L | grep sql
ACCEPT tcp — anywhere 172.21.0.2 tcp dpt:mysql

ufw status verbose
22/tcp LIMIT IN Anywhere
2375/tcp ALLOW IN Anywhere
2376/tcp ALLOW IN Anywhere
22/tcp (v6) LIMIT IN Anywhere (v6)
2375/tcp (v6) ALLOW IN Anywhere (v6)
2376/tcp (v6) ALLOW IN Anywhere (v6)


Ясно, надо смотреть напрямую в iptables
Да уж, докер с ufw, смешать но не взбалтывать. Еще netplan-ом сбоку поперчить осталось, а вся магия вообще в другой таблице делается:
iptables -L -t nat -vn
Chain PREROUTING (policy ACCEPT 33M packets, 9180M bytes)
pkts bytes target prot opt in out source destination
2756K 207M DOCKER all -- * * 0.0.0.0/0 0.0.0.0/0 ADDRTYPE match dst-type LOCAL

Chain INPUT (policy ACCEPT 8567K packets, 935M bytes)
pkts bytes target prot opt in out source destination

Chain OUTPUT (policy ACCEPT 2552K packets, 170M bytes)
pkts bytes target prot opt in out source destination
976K 59M DOCKER all -- * * 0.0.0.0/0 !127.0.0.0/8 ADDRTYPE match dst-type LOCAL

Chain POSTROUTING (policy ACCEPT 1578K packets, 111M bytes)
pkts bytes target prot opt in out source destination
3635K 230M MASQUERADE all -- * !docker0 172.17.0.0/16 0.0.0.0/0
5230 267K MASQUERADE all -- * !br-2ff103b05111 172.20.0.0/16 0.0.0.0/0
0 0 MASQUERADE all -- * !br-c2f97d6056ec 172.18.0.0/16 0.0.0.0/0
0 0 MASQUERADE all -- * !br-60c04f155cca 172.19.0.0/16 0.0.0.0/0
0 0 MASQUERADE tcp -- * * 172.20.0.2 172.20.0.2 tcp dpt:8080
0 0 MASQUERADE tcp -- * * 172.17.0.2 172.17.0.2 tcp dpt:4679
0 0 MASQUERADE tcp -- * * 172.17.0.3 172.17.0.3 tcp dpt:80
0 0 MASQUERADE tcp -- * * 172.17.0.4 172.17.0.4 tcp dpt:3000
0 0 MASQUERADE tcp -- * * 172.17.0.5 172.17.0.5 tcp dpt:8080

Chain DOCKER (2 references)
pkts bytes target prot opt in out source destination
0 0 RETURN all -- docker0 * 0.0.0.0/0 0.0.0.0/0
0 0 RETURN all -- br-2ff103b05111 * 0.0.0.0/0 0.0.0.0/0
0 0 RETURN all -- br-c2f97d6056ec * 0.0.0.0/0 0.0.0.0/0
0 0 RETURN all -- br-60c04f155cca * 0.0.0.0/0 0.0.0.0/0
325 16900 DNAT tcp -- !br-2ff103b05111 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:8083 to:172.20.0.2:8080
27 1368 DNAT tcp -- !docker0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:8082 to:172.17.0.2:4679
2283 119K DNAT tcp -- !docker0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:8081 to:172.17.0.3:80
217 11284 DNAT tcp -- !docker0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:8084 to:172.17.0.4:3000
0 0 DNAT tcp -- !docker0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:8080 to:172.17.0.5:8080

Статья в тему
medium.com/@ebuschini/iptables-and-docker-95e2496f0b45
Скрытый текст
Let’s say you have a container that listen on port 443. You only want to allow traffic from your load balancers as it handles some of the security for you. Nothing really hard right?

The naive approach is to create a rules on the default INPUT chain which will have kind of the following:

iptables -A INPUT -p tcp --dport 443 -s 172.16.0.0/26 -m state --state NEW,ESTABLISHED

This rule says: allow new and established inbound traffic from the 172.16.0.0/26 network to the port 443 on the tcp protocol.

You put your iptables -A INPUT -j DROP at the end and then you are happy because you think it works! So you try from your machine and the port is still open for you. Hummm, weird?

Все это получается на базе Digital Ocean
На старте виртуалка пишет
Welcome to DigitalOcean's One-Click Docker Droplet.
To keep this Droplet secure, the UFW firewall is enabled.
All ports are BLOCKED except 22 (SSH), 2375 (Docker) and 2376 (Docker).

я, далекий от администрирования, этому верю (думая что касается и контейнеров тоже), а потом все доступно снаружи

Спасибо за ссылку на медиум, я сейчас ищу как настроить чтобы было доступно только «изнутри»
авторизация доступна в basic лицензии с версии 7.1.0 (Release date:
May 20, 2019) и 6.8
Я считаю, что это всё же проблема HTTP, раз уж настройки по умолчанию позволяют подключиться к нему всему миру.

Вы сравнивание тёплое с мягким (протокол с его реализацией). Апач ведь в дефолтной инсталляции не позволяет шариться по всей файловой системе сервера, в отличии от эластика, который, между прочим, тоже можно считать реализацией http сервера.

>протокол с его реализацией
я просто не стал перечислять apache/nginx/lighthttpd/тысячи их
где это еластик «позволяет шариться по всей файловой системе сервера» даже если он открыт всему миру?
Я оповестил сервис «Слетать.ру» 15.05.2019 в 10:46 (МСК) и через несколько часов (до 16:00) он исчез их свободного доступа.
Слетать.ру исчез? :)))
да, неудачно выразился ;)
Я помню времена, когда уязвимые хосты искались в гугле специально составленным запросом(SQL — вариант).

В данном топике примерно тоже самое, только уже ищут по портам или ещё каким маякам и очень не исключен вариант, когда на этих ребят с расшаренным доступом к персональным данным достучались люди, не только с белыми шапками, но с черными.

Когда уже будет адекватная ответственность или способ влияния за такое безалаберное отношение(или, что хуже, специально запланированный слив) к персональным данным многих людей.
То есть им очень повезло, что никто DELETE не сделал.
Sign up to leave a comment.

Articles